mirror of
https://github.com/nushell/nushell
synced 2024-12-29 06:23:11 +00:00
Allow passing block literals to do (#4798)
This commit is contained in:
parent
355b1d9929
commit
be43b3c5fc
1 changed files with 15 additions and 5 deletions
|
@ -18,11 +18,7 @@ impl Command for Do {
|
||||||
fn signature(&self) -> nu_protocol::Signature {
|
fn signature(&self) -> nu_protocol::Signature {
|
||||||
Signature::build("do")
|
Signature::build("do")
|
||||||
.desc(self.usage())
|
.desc(self.usage())
|
||||||
.required(
|
.required("block", SyntaxShape::Any, "the block to run")
|
||||||
"block",
|
|
||||||
SyntaxShape::Block(Some(vec![])),
|
|
||||||
"the block to run",
|
|
||||||
)
|
|
||||||
.switch(
|
.switch(
|
||||||
"ignore-errors",
|
"ignore-errors",
|
||||||
"ignore errors as the block runs",
|
"ignore errors as the block runs",
|
||||||
|
@ -115,6 +111,20 @@ impl Command for Do {
|
||||||
example: r#"do -i { thisisnotarealcommand }"#,
|
example: r#"do -i { thisisnotarealcommand }"#,
|
||||||
result: None,
|
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 {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue