Repository: clap-rs/clap (language: rust)

Issue:
help/version env parsing is different than other flags
help/version flags just care about presence while other bool flags parse the value.  We should unifiy these so they all parse the value.


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eaab232c81b..f83d010bcb4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
 - *(derive)* `subcommand_required(true).arg_required_else_help(true)` is set instead of `SubcommandRequiredElseHelp`
 
 ### Features
diff --git a/src/parser/parser.rs b/src/parser/parser.rs
index 3821f9d63fd..3529e848f9b 100644
--- a/src/parser/parser.rs
+++ b/src/parser/parser.rs
@@ -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);
@@ -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)?;
-                        }
                     }
                 }
             }


Test patch: