mirror of
https://github.com/nushell/nushell.git
synced 2024-11-27 10:53:57 +01:00
f85a1d003c
* throw error when multiple short flags are defined without whitespace * add tests
33 lines
769 B
Rust
33 lines
769 B
Rust
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
use std::fs;
|
|
|
|
#[test]
|
|
fn def_with_comment() {
|
|
Playground::setup("def_with_comment", |dirs, _| {
|
|
let data = r#"
|
|
#My echo
|
|
def e [arg] {echo $arg}
|
|
"#;
|
|
fs::write(dirs.root().join("def_test"), data).expect("Unable to write file");
|
|
let actual = nu!(
|
|
cwd: dirs.root(),
|
|
"source def_test; help e | to json -r"
|
|
);
|
|
|
|
assert!(actual.out.contains("My echo\\n\\n"));
|
|
});
|
|
}
|
|
|
|
#[test]
|
|
fn def_errors_with_multiple_short_flags() {
|
|
let actual = nu!(
|
|
cwd: ".", pipeline(
|
|
r#"
|
|
def test-command [ --long(-l)(-o) ] {}
|
|
"#
|
|
));
|
|
|
|
assert!(actual.err.contains("expected one short flag"));
|
|
}
|