Skip to content

Commit

Permalink
Allow passing block literals to do (#4798)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiajt committed Mar 9, 2022
1 parent 355b1d9 commit be43b3c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions crates/nu-command/src/core_commands/do_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ impl Command for Do {
fn signature(&self) -> nu_protocol::Signature {
Signature::build("do")
.desc(self.usage())
.required(
"block",
SyntaxShape::Block(Some(vec![])),
"the block to run",
)
.required("block", SyntaxShape::Any, "the block to run")
.switch(
"ignore-errors",
"ignore errors as the block runs",
Expand Down Expand Up @@ -115,6 +111,20 @@ impl Command for Do {
example: r#"do -i { thisisnotarealcommand }"#,
result: None,
},
Example {
description: "Run the block, with a positional parameter",
example: r#"do {|x| 100 + $x } 50"#,
result: Some(Value::test_int(150)),
},
]
}
}

mod test {
#[test]
fn test_examples() {
use super::Do;
use crate::test_examples;
test_examples(Do {})
}
}

0 comments on commit be43b3c

Please sign in to comment.