From d0bca1fb0f610fbc423b542c04e7384b382af8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= <andres@androbtech.com> Date: Tue, 15 Jun 2021 18:26:04 -0500 Subject: [PATCH] Remove 'help' Nu bin positional support. (#3621) Mostly to keep parity with the rest of Nu internal commands (`-h` and `--help`) instead. --- crates/nu-cli/src/app.rs | 27 ++++---------------- crates/nu-command/src/commands/nu/command.rs | 10 ++++---- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/crates/nu-cli/src/app.rs b/crates/nu-cli/src/app.rs index 8d0cf9f28e..7c3ced79bc 100644 --- a/crates/nu-cli/src/app.rs +++ b/crates/nu-cli/src/app.rs @@ -153,27 +153,10 @@ impl App { } pub fn help(&self) -> bool { - let help_asked = self - .options - .get("args") - .map(|v| { - v.table_entries().next().map(|v| { - if let Ok(value) = v.as_string() { - value == "help" - } else { - false - } - }) - }) - .flatten() - .unwrap_or(false); - - if help_asked { - self.options.shift(); - return true; - } - - false + self.options + .get("help") + .map(|v| matches!(v.as_bool(), Ok(true))) + .unwrap_or(false) } pub fn scripts(&self) -> Option<Vec<Result<String, ShellError>>> { @@ -408,7 +391,7 @@ mod tests { fn has_help() -> Result<(), ShellError> { let ui = cli_app(); - ui.parse("nu help")?; + ui.parse("nu --help")?; assert_eq!(ui.help(), true); Ok(()) } diff --git a/crates/nu-command/src/commands/nu/command.rs b/crates/nu-command/src/commands/nu/command.rs index 668657cc6b..e8b5700a25 100644 --- a/crates/nu-command/src/commands/nu/command.rs +++ b/crates/nu-command/src/commands/nu/command.rs @@ -13,11 +13,11 @@ impl WholeStreamCommand for Command { .switch("stdin", "stdin", None) .switch("skip-plugins", "do not load plugins", None) .switch("no-history", "don't save history", None) - .named("commands", SyntaxShape::String, "Nu commands", Some('c')) + .named("commands", SyntaxShape::String, "commands", Some('c')) .named( "testbin", SyntaxShape::String, - "BIN: echo_env, cococo, iecho, fail, nonu, chop, repeater, meow", + "test bin: echo_env, cococo, iecho, fail, nonu, chop, repeater, meow", None, ) .named("develop", SyntaxShape::String, "trace mode", None) @@ -34,12 +34,12 @@ impl WholeStreamCommand for Command { "custom configuration source file", None, ) - .optional("script", SyntaxShape::FilePath, "The Nu script to run") - .rest(SyntaxShape::String, "Left overs...") + .optional("script", SyntaxShape::FilePath, "script to run") + .rest(SyntaxShape::String, "...") } fn usage(&self) -> &str { - "Nu" + "Nu - A new type of shell." } }