diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-07-19 00:22:23 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-07-19 00:27:16 +0800 |
| commit | 5e460470f6ea2ce31a403b6e936ec2fe8f45312a (patch) | |
| tree | ec1d675d9544b31ab9382ebbd10bbeda43923cc8 /mingling/src/setups/picker/basic.rs | |
| parent | 9b4cffd48482481691f782e74a4726294043bc57 (diff) | |
feat: migrate mingling-specific picker code into mingling crate
BREAKING CHANGE: Remove `mingling_support` feature from arg-picker
crate. The
`EntryPicker` trait and `corebind` module are now part of the mingling
crate
directly, and `build_pattern1` is now a public method.
Diffstat (limited to 'mingling/src/setups/picker/basic.rs')
| -rw-r--r-- | mingling/src/setups/picker/basic.rs | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/mingling/src/setups/picker/basic.rs b/mingling/src/setups/picker/basic.rs index 318edbd..b8cc237 100644 --- a/mingling/src/setups/picker/basic.rs +++ b/mingling/src/setups/picker/basic.rs @@ -1,27 +1,11 @@ -use arg_picker::{IntoPicker, PickerArg, value::Flag}; +use arg_picker::{PickerArg, value::Flag}; use mingling_core::{Program, ProgramCollect, setup::ProgramSetup}; use crate::{ - setup::picker::REMAINS, - setups::picker::{CONFIRM_FLAG, HELP_FLAG, QUIET_FLAG}, + consts::{CONFIRM_FLAG, HELP_FLAG, QUIET_FLAG}, + picker::pick_global_flag, }; -/// Helper: picks a boolean flag from the program arguments, calls `f` with the -/// flag value, then replaces the program arguments with the remaining args. -fn pick_flag<'a, C>( - program: &mut Program<C>, - flag: &PickerArg<'a, Flag>, - f: impl FnOnce(bool, &mut Program<C>), -) where - C: ProgramCollect<Enum = C>, -{ - let args = program.take_args(); - let remains_arg = PickerArg::<PickerArgs<'a>>::new(&[], None, true); - let (active, remains) = args.pick(flag).pick(&remains_arg).unwrap(); - f(*active, program); - program.replace_args(remains.into()); -} - /// Performs basic program initialization: /// /// - Collects `--quiet` flag to control message rendering @@ -59,9 +43,7 @@ where C: ProgramCollect<Enum = C>, { fn setup(self, program: &mut Program<C>) { - pick_flag(program, self.flag, |active, ctx| { - ctx.user_context.help = active; - }); + pick_global_flag(program, self.flag); } } @@ -90,12 +72,7 @@ where C: ProgramCollect<Enum = C>, { fn setup(self, program: &mut Program<C>) { - pick_flag(program, self.flag, |active, ctx| { - if active { - ctx.stdout_setting.render_output = false; - ctx.stdout_setting.error_output = false; - } - }); + pick_global_flag(program, self.flag); } } @@ -124,11 +101,7 @@ where C: ProgramCollect<Enum = C>, { fn setup(self, program: &mut Program<C>) { - pick_flag(program, self.flag, |active, ctx| { - if active { - ctx.user_context.confirm = true; - } - }); + pick_global_flag(program, self.flag); } } |
