mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Fix help flag (#4398)
* Match 'help command' to 'command --help' * Fix tests
This commit is contained in:
parent
e1f98c1bfd
commit
c2118e7505
3 changed files with 9 additions and 10 deletions
|
@ -56,7 +56,7 @@ fn test_cd_html_color_flag_dark_false() {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual.out,
|
actual.out,
|
||||||
r"<html><style>body { background-color:white;color:black; }</style><body>Usage:<br> > cd (path) <br><br>Flags:<br> -h, --help<br> Display this help message<br><br>Parameters:<br> (optional) path: the path to change to<br><br></body></html>"
|
r"<html><style>body { background-color:white;color:black; }</style><body>Change directory.<br><br>Usage:<br> > cd (path) <br><br>Flags:<br> -h, --help<br> Display this help message<br><br>Parameters:<br> (optional) path: the path to change to<br><br></body></html>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ fn test_no_color_flag() {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual.out,
|
actual.out,
|
||||||
r"<html><style>body { background-color:white;color:black; }</style><body>Usage:<br> > cd (path) <br><br>Flags:<br> -h, --help<br> Display this help message<br><br>Parameters:<br> (optional) path: the path to change to<br><br></body></html>"
|
r"<html><style>body { background-color:white;color:black; }</style><body>Change directory.<br><br>Usage:<br> > cd (path) <br><br>Flags:<br> -h, --help<br> Display this help message<br><br>Parameters:<br> (optional) path: the path to change to<br><br></body></html>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,6 @@ fn test_html_color_where_flag_dark_false() {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
actual.out,
|
actual.out,
|
||||||
r"<html><style>body { background-color:white;color:black; }</style><body>Usage:<br> > where <cond> <br><br>Flags:<br> -h, --help<br> Display this help message<br><br>Parameters:<br> cond: condition<br><br></body></html>"
|
r"<html><style>body { background-color:white;color:black; }</style><body>Filter values based on a condition.<br><br>Usage:<br> > where <cond> <br><br>Flags:<br> -h, --help<br> Display this help message<br><br>Parameters:<br> cond: condition<br><br></body></html>"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,11 @@ fn eval_call(
|
||||||
let decl = engine_state.get_decl(call.decl_id);
|
let decl = engine_state.get_decl(call.decl_id);
|
||||||
|
|
||||||
if call.named.iter().any(|(flag, _)| flag.item == "help") {
|
if call.named.iter().any(|(flag, _)| flag.item == "help") {
|
||||||
let full_help = get_full_help(
|
let mut signature = decl.signature();
|
||||||
&decl.signature(),
|
signature.usage = decl.usage().to_string();
|
||||||
&decl.examples(),
|
signature.extra_usage = decl.extra_usage().to_string();
|
||||||
engine_state,
|
|
||||||
caller_stack,
|
let full_help = get_full_help(&signature, &decl.examples(), engine_state, caller_stack);
|
||||||
);
|
|
||||||
Ok(Value::String {
|
Ok(Value::String {
|
||||||
val: full_help,
|
val: full_help,
|
||||||
span: call.head,
|
span: call.head,
|
||||||
|
|
|
@ -72,7 +72,7 @@ fn in_variable_6() -> TestResult {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_works_with_missing_requirements() -> TestResult {
|
fn help_works_with_missing_requirements() -> TestResult {
|
||||||
run_test(r#"each --help | lines | length"#, "20")
|
run_test(r#"each --help | lines | length"#, "22")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue