forked from extern/nushell
suppress the parser error for an insufficient number of required arguments if the named keyword argument 'help' is given (#1659)
This commit is contained in:
@ -976,11 +976,14 @@ fn parse_internal_command(
|
||||
}
|
||||
}
|
||||
if positional.len() < required_arg_count && error.is_none() {
|
||||
let (_, name) = &signature.positional[positional.len()];
|
||||
error = Some(ParseError::argument_error(
|
||||
lite_cmd.name.clone(),
|
||||
ArgumentError::MissingMandatoryPositional(name.to_owned()),
|
||||
));
|
||||
// to make "command -h" work even if required arguments are missing
|
||||
if !named.named.contains_key("help") {
|
||||
let (_, name) = &signature.positional[positional.len()];
|
||||
error = Some(ParseError::argument_error(
|
||||
lite_cmd.name.clone(),
|
||||
ArgumentError::MissingMandatoryPositional(name.to_owned()),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if !named.is_empty() {
|
||||
|
Reference in New Issue
Block a user