Skip to content

Commit

Permalink
fix(env)!: Parse help/version like normal
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 22, 2022
1 parent 50019ca commit 96cd86b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- `ErrorKind::EmptyValue` replaced with `ErrorKind::InvalidValue`
- `ErrorKind::UnrecognizedSubcommand` replaced with `ErrorKind::InvalidSubcommand`
- *(env)* Parse `--help` and `--version` like any `ArgAction::SetTrue` flag

### Features

Expand Down
9 changes: 3 additions & 6 deletions src/parser/parser.rs
Expand Up @@ -1395,7 +1395,9 @@ impl<'help, 'cmd> Parser<'help, 'cmd> {
| ArgAction::Append
| ArgAction::SetTrue
| ArgAction::SetFalse
| ArgAction::Count => {
| ArgAction::Count
| ArgAction::Help
| ArgAction::Version => {
let mut arg_values = Vec::new();
let _parse_result =
self.split_arg_values(arg, &val, trailing_values, &mut arg_values);
Expand All @@ -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)?;
}
}
}
}
Expand Down

0 comments on commit 96cd86b

Please sign in to comment.