Add experimental support for flags in custom commands (#2808)

* Add experimental support for flags in custom commands

* clippy
This commit is contained in:
Jonathan Turner
2020-12-21 20:36:59 +13:00
committed by GitHub
parent 67acaae53c
commit c012d648fb
4 changed files with 148 additions and 33 deletions

View File

@ -344,6 +344,30 @@ fn run_custom_command() {
assert_eq!(actual.out, "15");
}
#[test]
fn run_custom_command_with_flag() {
let actual = nu!(
cwd: ".",
r#"
def foo [--bar:number] { if $(echo $bar | empty?) { echo "empty" } { echo $bar } }; foo --bar 10
"#
);
assert_eq!(actual.out, "10");
}
#[test]
fn run_custom_command_with_flag_missing() {
let actual = nu!(
cwd: ".",
r#"
def foo [--bar:number] { if $(echo $bar | empty?) { echo "empty" } { echo $bar } }; foo
"#
);
assert_eq!(actual.out, "empty");
}
#[test]
fn set_variable() {
let actual = nu!(