From d272f0d3b8f7bcfe05ec94ce7163affc29d9a98e Mon Sep 17 00:00:00 2001 From: NotTheDr01ds <32344964+NotTheDr01ds@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:54:24 -0400 Subject: [PATCH] Added two examples (and fixed another) --- crates/nu-cmd-lang/src/core_commands/do_.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/nu-cmd-lang/src/core_commands/do_.rs b/crates/nu-cmd-lang/src/core_commands/do_.rs index 8ca3fbac56..2da411d3a5 100644 --- a/crates/nu-cmd-lang/src/core_commands/do_.rs +++ b/crates/nu-cmd-lang/src/core_commands/do_.rs @@ -234,9 +234,19 @@ impl Command for Do { result: Some(Value::test_int(177)), }, Example { - description: "Run the closure, with input", - example: r#"77 | do {|x| 100 + $in }"#, - result: None, // TODO: returns 177 + description: "Run the closure, with pipeline input", + example: r#"77 | do {100 + $in }"#, + result: Some(Value::test_int(177)), + }, + Example { + description: "Run the closure, with a default parameter value", + example: r#"77 | do {|x=100| $x + $in }"#, + result: Some(Value::test_int(177)), + }, + Example { + description: "Run the closure, with two positional parameters", + example: r#"do {|x,y| $x + $y } 77 100"#, + result: Some(Value::test_int(177)), }, Example { description: "Run the closure and keep changes to the environment",