mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
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:
parent
d51945f8b8
commit
65b3f66753
5 changed files with 5 additions and 0 deletions
|
@ -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> {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue