fix: doesn't print the argument sections in the help message if all args in that section are hidden

This commit is contained in:
Kevin K 2017-03-04 15:35:18 -05:00
parent 539ad6073f
commit d63d404e5e
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A

View file

@ -557,6 +557,30 @@ impl<'a, 'b> Parser<'a, 'b>
#[inline]
pub fn has_subcommands(&self) -> bool { !self.subcommands.is_empty() }
#[inline]
pub fn has_visible_opts(&self) -> bool {
if self.opts.is_empty() { return false; }
self.opts.iter().any(|o| !o.is_set(ArgSettings::Hidden))
}
#[inline]
pub fn has_visible_flags(&self) -> bool {
if self.flags.is_empty() { return false; }
self.flags.iter().any(|f| !f.is_set(ArgSettings::Hidden))
}
#[inline]
pub fn has_visible_positionals(&self) -> bool {
if self.positionals.is_empty() { return false; }
self.positionals.values().any(|p| !p.is_set(ArgSettings::Hidden))
}
#[inline]
pub fn has_visible_subcommands(&self) -> bool {
if self.subcommands.is_empty() { return false; }
self.subcommands.iter().any(|s| !s.is_set(AppSettings::Hidden))
}
#[inline]
pub fn is_set(&self, s: AS) -> bool { self.settings.is_set(s) }