diff options
Diffstat (limited to 'mingling_picker/src')
| -rw-r--r-- | mingling_picker/src/builtin/pick_bool.rs | 5 | ||||
| -rw-r--r-- | mingling_picker/src/parselib.rs | 3 | ||||
| -rw-r--r-- | mingling_picker/src/parselib/flag_matcher.rs (renamed from mingling_picker/src/parselib/bool_matcher.rs) | 10 |
3 files changed, 14 insertions, 4 deletions
diff --git a/mingling_picker/src/builtin/pick_bool.rs b/mingling_picker/src/builtin/pick_bool.rs index 65efe47..673f2a3 100644 --- a/mingling_picker/src/builtin/pick_bool.rs +++ b/mingling_picker/src/builtin/pick_bool.rs @@ -1,4 +1,5 @@ -use crate::{parselib::Matcher, pickable_needed::*}; +use crate::parselib::{FlagMatcher, Matcher}; +use crate::pickable_needed::*; impl<'a> Pickable<'a> for bool { fn get_attr(_: &'a PickerFlag<'a, Self>) -> PickerFlagAttr { @@ -6,7 +7,7 @@ impl<'a> Pickable<'a> for bool { } fn tag(ctx: TagPhaseContext) -> Vec<usize> { - <bool as Matcher>::match_all(ctx.into()) + FlagMatcher::match_all(ctx.into()) } fn pick(raw_strs: &[&str]) -> PickerArgResult<Self> { diff --git a/mingling_picker/src/parselib.rs b/mingling_picker/src/parselib.rs index 5950c9d..cf550b7 100644 --- a/mingling_picker/src/parselib.rs +++ b/mingling_picker/src/parselib.rs @@ -1,4 +1,5 @@ -mod bool_matcher; +mod flag_matcher; +pub use flag_matcher::*; mod style; pub use style::*; diff --git a/mingling_picker/src/parselib/bool_matcher.rs b/mingling_picker/src/parselib/flag_matcher.rs index cbcb111..af890b9 100644 --- a/mingling_picker/src/parselib/bool_matcher.rs +++ b/mingling_picker/src/parselib/flag_matcher.rs @@ -4,7 +4,15 @@ use crate::{ vec_string_slice, }; -impl Matcher for bool { +/// `FlagMatcher` is used to match flags in command-line arguments. +/// +/// Flags typically start with `-` or `--` (e.g., `-h`, `--help`), +/// and do not carry additional values. This matcher is responsible for finding +/// these flags in the argument list, taking into account that flags after `--` +/// (end-of-options marker) should not be matched. +pub struct FlagMatcher; + +impl Matcher for FlagMatcher { fn on_match_one( args: &[MaskedArg], style: &ParserStyle, |
