forked from extern/nushell
Add experimental support for flags in custom commands (#2808)
* Add experimental support for flags in custom commands * clippy
This commit is contained in:
@ -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!(
|
||||
|
Reference in New Issue
Block a user