mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 06:12:40 +00:00
fix: fixes a bug that wasn't allowing help and version to be properly overridden
One should be able to override the auto generated help and version flags by simply providing an arg with a long of `help` or `version` respectively. This bug was preventing that from happening. However, now that it's fixed if one was relying on adding an arg with a long of `help` or `version` and using `get_matches_safe` to produce the `ErrorKind::HelpDisplayed` or `ErrorKind::VersionDisplayed` errors they **WILL NOT** happen anymore. This is because the bug was causing those "errors" to occur (i.e. the help or version message to be displayed). The "fix" to get that functionality back is to either: * Remove the arg with the long of `help` or `version` * Use `ArgMatches::is_present` instead of `App::get_matches_safe` to check for the presence of your custom help or version flag Option 1 is the easiest provided one wasn't using said arg to *also* override other aspects of the flags as well (short, help message, etc.) Even though this may break some code, as per the compatibility policy listed in the readme; code that breaks due to relying on a bug does *not* constitute a major version bump. I will however be bumping the minor version instead of just the patch version. I will also be searching for, contacting, and attempting to submit PRs to any affected projects prior to releasing the next version to crates.io Closes #922
This commit is contained in:
parent
92cc30577d
commit
8b2ceb8368
1 changed files with 7 additions and 0 deletions
|
@ -206,6 +206,13 @@ impl<'a, 'b> Parser<'a, 'b>
|
||||||
self.set(AS::DontCollapseArgsInUsage);
|
self.set(AS::DontCollapseArgsInUsage);
|
||||||
self.set(AS::ContainsLast);
|
self.set(AS::ContainsLast);
|
||||||
}
|
}
|
||||||
|
if let Some(l) = a.s.long {
|
||||||
|
if l == "version" {
|
||||||
|
self.unset(AS::NeedsLongVersion);
|
||||||
|
} else if l == "help" {
|
||||||
|
self.unset(AS::NeedsLongHelp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// actually adds the arguments
|
// actually adds the arguments
|
||||||
|
|
Loading…
Reference in a new issue