mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +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!(
|
||||
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!(
|
||||
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!(
|
||||
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);
|
||||
|
||||
if call.named.iter().any(|(flag, _)| flag.item == "help") {
|
||||
let full_help = get_full_help(
|
||||
&decl.signature(),
|
||||
&decl.examples(),
|
||||
engine_state,
|
||||
caller_stack,
|
||||
);
|
||||
let mut signature = decl.signature();
|
||||
signature.usage = decl.usage().to_string();
|
||||
signature.extra_usage = decl.extra_usage().to_string();
|
||||
|
||||
let full_help = get_full_help(&signature, &decl.examples(), engine_state, caller_stack);
|
||||
Ok(Value::String {
|
||||
val: full_help,
|
||||
span: call.head,
|
||||
|
|
|
@ -72,7 +72,7 @@ fn in_variable_6() -> TestResult {
|
|||
|
||||
#[test]
|
||||
fn help_works_with_missing_requirements() -> TestResult {
|
||||
run_test(r#"each --help | lines | length"#, "20")
|
||||
run_test(r#"each --help | lines | length"#, "22")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue