From 25349a1eacd5b83ae7945af019e2d1a054741bb3 Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Sat, 25 Jun 2022 17:27:54 +0800 Subject: [PATCH] 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 --- crates/nu-command/src/filters/default.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/nu-command/src/filters/default.rs b/crates/nu-command/src/filters/default.rs index 8f78323c0..5988f63a9 100644 --- a/crates/nu-command/src/filters/default.rs +++ b/crates/nu-command/src/filters/default.rs @@ -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",