imp(srs/args): Added longest_filter to AnyArg trait

This function allows providing an extra filter to remove elements when finding
the longest element.
This commit is contained in:
Hernan Grecco 2016-04-01 02:07:44 -03:00
parent d51945f8b8
commit 65b3f66753
5 changed files with 5 additions and 0 deletions

View file

@ -936,6 +936,7 @@ impl<'n, 'e> AnyArg<'n, 'e> for App<'n, 'e> {
fn takes_value(&self) -> bool { true }
fn help(&self) -> Option<&'e str> { self.p.meta.about }
fn default_val(&self) -> Option<&'n str> { None }
fn longest_filter(&self) -> bool { true }
}
impl<'n, 'e> fmt::Display for App<'n, 'e> {

View file

@ -25,6 +25,7 @@ pub trait AnyArg<'n, 'e> {
fn val_names(&self) -> Option<&VecMap<&'e str>>;
fn help(&self) -> Option<&'e str>;
fn default_val(&self) -> Option<&'n str>;
fn longest_filter(&self) -> bool;
}
pub trait DispOrder {

View file

@ -129,6 +129,7 @@ impl<'n, 'e> AnyArg<'n, 'e> for FlagBuilder<'n, 'e> {
fn val_delim(&self) -> Option<char> { None }
fn help(&self) -> Option<&'e str> { self.help }
fn default_val(&self) -> Option<&'n str> { None }
fn longest_filter(&self) -> bool { self.long.is_some() }
}
impl<'n, 'e> DispOrder for FlagBuilder<'n, 'e> {

View file

@ -193,6 +193,7 @@ impl<'n, 'e> AnyArg<'n, 'e> for OptBuilder<'n, 'e> {
fn takes_value(&self) -> bool { true }
fn help(&self) -> Option<&'e str> { self.help }
fn default_val(&self) -> Option<&'n str> { self.default_val }
fn longest_filter(&self) -> bool { true }
}
impl<'n, 'e> DispOrder for OptBuilder<'n, 'e> {

View file

@ -180,6 +180,7 @@ impl<'n, 'e> AnyArg<'n, 'e> for PosBuilder<'n, 'e> {
fn takes_value(&self) -> bool { true }
fn help(&self) -> Option<&'e str> { self.help }
fn default_val(&self) -> Option<&'n str> { self.default_val }
fn longest_filter(&self) -> bool { true }
}
impl<'n, 'e> DispOrder for PosBuilder<'n, 'e> {