Allow different names for ...rest (#3954)

* Allow different names for ...rest

* Resolves #3945

* This change requires an explicit name for the rest argument in `WholeStreamCommand`,
  which is why there are so many changed files.

* Remove redundant clone

* Add tests
This commit is contained in:
Hristo Filaretov
2021-08-26 19:58:53 +02:00
committed by GitHub
parent 88817a8f10
commit b8e2bdd6b1
97 changed files with 270 additions and 87 deletions

View File

@ -373,6 +373,25 @@ fn run_custom_command_with_empty_rest() {
assert_eq!(actual.err, r#""#);
}
#[test]
fn run_custom_command_with_rest_other_name() {
let actual = nu!(
cwd: ".",
r#"
def say-hello [
greeting:string,
...names:string # All of the names
] {
echo $"($greeting), ($names | sort-by | str collect ' ')"
}
say-hello Salutations E D C A B
"#
);
assert_eq!(actual.out, r#"Salutations, A B C D E"#);
assert_eq!(actual.err, r#""#);
}
#[test]
fn alias_a_load_env() {
let actual = nu!(