aboutsummaryrefslogtreecommitdiff
path: root/mingling_picker/src/builtin/pick_bool.rs
blob: 673f2a3972cba29a612f43282d9146a58c2807d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::parselib::{FlagMatcher, Matcher};
use crate::pickable_needed::*;

impl<'a> Pickable<'a> for bool {
    fn get_attr(_: &'a PickerFlag<'a, Self>) -> PickerFlagAttr {
        PickerFlagAttr::Flag
    }

    fn tag(ctx: TagPhaseContext) -> Vec<usize> {
        FlagMatcher::match_all(ctx.into())
    }

    fn pick(raw_strs: &[&str]) -> PickerArgResult<Self> {
        if raw_strs.is_empty() {
            // No matching flag found — signal NotFound so the fallback chain
            // (default → route) gets a chance to run.
            PickerArgResult::NotFound
        } else {
            PickerArgResult::Parsed(true)
        }
    }
}