Remove 'help' Nu bin positional support. (#3621)

Mostly to keep parity with the rest of Nu internal commands (`-h` and `--help`) instead.
This commit is contained in:
Andrés N. Robalino 2021-06-15 18:26:04 -05:00 committed by GitHub
parent 7c7e5112ea
commit d0bca1fb0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 27 deletions

View File

@ -153,27 +153,10 @@ impl App {
} }
pub fn help(&self) -> bool { pub fn help(&self) -> bool {
let help_asked = self self.options
.options .get("help")
.get("args") .map(|v| matches!(v.as_bool(), Ok(true)))
.map(|v| { .unwrap_or(false)
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
} }
pub fn scripts(&self) -> Option<Vec<Result<String, ShellError>>> { pub fn scripts(&self) -> Option<Vec<Result<String, ShellError>>> {
@ -408,7 +391,7 @@ mod tests {
fn has_help() -> Result<(), ShellError> { fn has_help() -> Result<(), ShellError> {
let ui = cli_app(); let ui = cli_app();
ui.parse("nu help")?; ui.parse("nu --help")?;
assert_eq!(ui.help(), true); assert_eq!(ui.help(), true);
Ok(()) Ok(())
} }

View File

@ -13,11 +13,11 @@ impl WholeStreamCommand for Command {
.switch("stdin", "stdin", None) .switch("stdin", "stdin", None)
.switch("skip-plugins", "do not load plugins", None) .switch("skip-plugins", "do not load plugins", None)
.switch("no-history", "don't save history", 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( .named(
"testbin", "testbin",
SyntaxShape::String, SyntaxShape::String,
"BIN: echo_env, cococo, iecho, fail, nonu, chop, repeater, meow", "test bin: echo_env, cococo, iecho, fail, nonu, chop, repeater, meow",
None, None,
) )
.named("develop", SyntaxShape::String, "trace mode", None) .named("develop", SyntaxShape::String, "trace mode", None)
@ -34,12 +34,12 @@ impl WholeStreamCommand for Command {
"custom configuration source file", "custom configuration source file",
None, None,
) )
.optional("script", SyntaxShape::FilePath, "The Nu script to run") .optional("script", SyntaxShape::FilePath, "script to run")
.rest(SyntaxShape::String, "Left overs...") .rest(SyntaxShape::String, "...")
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
"Nu" "Nu - A new type of shell."
} }
} }