diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-18 05:31:20 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-18 05:31:20 +0800 |
| commit | e89608805efe7a24ab72b8030bc307b6a4f6d6fc (patch) | |
| tree | fc722c41194d28f694ece2a21fd3902a0246c9cd /arg_picker/src/builtin | |
| parent | e525ad90af0295e7f6b4f16367ba12a6d88abfb4 (diff) | |
feat(arg_picker): add preprocessing and postprocessing priority levels
Add `Begin`, `Preprocess`, `Final`, and `Postprocess` variants to
`PickerArgAttr` enum, and implement `Pickable` for `PickerArgs` as a
built-in picker that consumes all remaining unclaimed arguments at
lowest priority. Expose `is_masked` and `build_masked_args` as public
functions for use by custom pickers.
Diffstat (limited to 'arg_picker/src/builtin')
| -rw-r--r-- | arg_picker/src/builtin/pick_picker_args.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/arg_picker/src/builtin/pick_picker_args.rs b/arg_picker/src/builtin/pick_picker_args.rs new file mode 100644 index 0000000..419cbc8 --- /dev/null +++ b/arg_picker/src/builtin/pick_picker_args.rs @@ -0,0 +1,21 @@ +use crate::{PickerArgResult::Parsed, PickerArgs, parselib::build_masked_args, pickable_needed::*}; + +impl<'a> Pickable<'a> for PickerArgs<'a> { + fn get_attr(_flag: &'a PickerArg<'a, Self>) -> PickerArgAttr { + // Use the lowest priority attribute + PickerArgAttr::Postprocess + } + + fn tag(ctx: TagPhaseContext) -> Vec<usize> { + // Collect all remaining raw index values + build_masked_args(ctx.args, ctx.mask) + .iter() + .map(|m| m.raw_idx) + .collect() + } + + fn pick(raw_strs: &[&str]) -> PickerArgResult<Self> { + let remains: Vec<String> = raw_strs.iter().map(|s| s.to_string()).collect(); + Parsed(PickerArgs::Owned(remains)) + } +} |
