mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
Merge pull request #3973 from epage/help-env
fix(env)!: Parse help/version like normal
This commit is contained in:
commit
d162b846ca
2 changed files with 4 additions and 6 deletions
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
- `ErrorKind::EmptyValue` replaced with `ErrorKind::InvalidValue`
|
- `ErrorKind::EmptyValue` replaced with `ErrorKind::InvalidValue`
|
||||||
- `ErrorKind::UnrecognizedSubcommand` replaced with `ErrorKind::InvalidSubcommand`
|
- `ErrorKind::UnrecognizedSubcommand` replaced with `ErrorKind::InvalidSubcommand`
|
||||||
|
- *(env)* Parse `--help` and `--version` like any `ArgAction::SetTrue` flag
|
||||||
- *(derive)* `subcommand_required(true).arg_required_else_help(true)` is set instead of `SubcommandRequiredElseHelp`
|
- *(derive)* `subcommand_required(true).arg_required_else_help(true)` is set instead of `SubcommandRequiredElseHelp`
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
|
@ -1395,7 +1395,9 @@ impl<'help, 'cmd> Parser<'help, 'cmd> {
|
||||||
| ArgAction::Append
|
| ArgAction::Append
|
||||||
| ArgAction::SetTrue
|
| ArgAction::SetTrue
|
||||||
| ArgAction::SetFalse
|
| ArgAction::SetFalse
|
||||||
| ArgAction::Count => {
|
| ArgAction::Count
|
||||||
|
| ArgAction::Help
|
||||||
|
| ArgAction::Version => {
|
||||||
let mut arg_values = Vec::new();
|
let mut arg_values = Vec::new();
|
||||||
let _parse_result =
|
let _parse_result =
|
||||||
self.split_arg_values(arg, &val, trailing_values, &mut arg_values);
|
self.split_arg_values(arg, &val, trailing_values, &mut arg_values);
|
||||||
|
@ -1412,11 +1414,6 @@ impl<'help, 'cmd> Parser<'help, 'cmd> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Early return on `Help` or `Version`.
|
|
||||||
ArgAction::Help | ArgAction::Version => {
|
|
||||||
let _ =
|
|
||||||
self.react(None, ValueSource::EnvVariable, arg, vec![], matcher)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue