fix: fixes bug where one can't override version or help flags

Closes #514
This commit is contained in:
Kevin K 2016-05-30 06:12:21 -04:00
parent 24423e661e
commit 90d7d6a2ea

View file

@ -115,9 +115,9 @@ impl<'a, 'b> Parser<'a, 'b>
l));
self.long_list.push(l);
if l == "help" {
self.set(AppSettings::NeedsLongHelp);
self.unset(AppSettings::NeedsLongHelp);
} else if l == "version" {
self.set(AppSettings::NeedsLongVersion);
self.unset(AppSettings::NeedsLongVersion);
}
}
if a.is_set(ArgSettings::Required) {
@ -378,6 +378,10 @@ impl<'a, 'b> Parser<'a, 'b>
self.settings.set(s)
}
pub fn unset(&mut self, s: AppSettings) {
self.settings.unset(s)
}
pub fn verify_positionals(&mut self) {
// Because you must wait until all arguments have been supplied, this is the first chance
// to make assertions on positional argument indexes
@ -929,13 +933,13 @@ impl<'a, 'b> Parser<'a, 'b>
debug!("Checking if -{} is help or version...", arg);
if let Some(h) = self.help_short {
sdebugln!("Help");
if arg == h {
if arg == h && self.settings.is_set(AppSettings::NeedsLongHelp) {
try!(self._help());
}
}
if let Some(v) = self.version_short {
sdebugln!("Help");
if arg == v {
if arg == v && self.settings.is_set(AppSettings::NeedsLongVersion) {
try!(self._version());
}
}