Add an example for default command to get an env var with fallback (#5874)

* Add an example for `default` command to get an env var with fallback

* update test

* update test
This commit is contained in:
Justin Ma 2022-06-25 17:27:54 +08:00 committed by GitHub
parent 99e4c44862
commit 25349a1eac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,6 +43,12 @@ impl Command for Default {
example: "ls -la | default 'nothing' target ",
result: None,
},
Example {
description:
"Get the env value of `MY_ENV` with a default value 'abc' if not present",
example: "$env | get -i MY_ENV | default 'abc'",
result: None, // Some(Value::test_string("abc")),
},
Example {
description: "Default the `$nothing` value in a list",
example: "[1, 2, $nothing, 4] | default 3",