Skip to content

Commit

Permalink
imp(srs/args): Added longest_filter to AnyArg trait
Browse files Browse the repository at this point in the history
This function allows providing an extra filter to remove elements when finding
the longest element.
  • Loading branch information
hgrecco committed Apr 13, 2016
1 parent d51945f commit 65b3f66
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
1 change: 1 addition & 0 deletions src/args/any_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/args/arg_builder/flag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
1 change: 1 addition & 0 deletions src/args/arg_builder/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
1 change: 1 addition & 0 deletions src/args/arg_builder/positional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 65b3f66

Please sign in to comment.