aboutsummaryrefslogtreecommitdiff
path: root/mingling/src/setups/picker
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-03 14:46:37 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-03 14:48:59 +0800
commit0ddfcbd044aa2a35f716f8d9b18c056dd6ec46af (patch)
tree4b26fa053cea41ef730c0da72f1d796ac785ef0f /mingling/src/setups/picker
parent52a448ca246d60f4cf88bdcde73bfed0f989c848 (diff)
refactor(picker): replace global picker functions with PickerHelper
trait
Diffstat (limited to 'mingling/src/setups/picker')
-rw-r--r--mingling/src/setups/picker/basic.rs8
-rw-r--r--mingling/src/setups/picker/structural_renderer.rs19
2 files changed, 12 insertions, 15 deletions
diff --git a/mingling/src/setups/picker/basic.rs b/mingling/src/setups/picker/basic.rs
index c9f82b3..52bda3d 100644
--- a/mingling/src/setups/picker/basic.rs
+++ b/mingling/src/setups/picker/basic.rs
@@ -3,7 +3,7 @@ use mingling_core::{Program, ProgramCollect, setup::ProgramSetup};
use crate::{
consts::{CONFIRM_FLAG, HELP_FLAG, QUIET_FLAG},
- picker::pick_global_flag,
+ picker::PickerHelper,
};
/// Performs basic program initialization:
@@ -43,7 +43,7 @@ where
C: ProgramCollect<Enum = C>,
{
fn setup(self, program: &mut Program<C>) {
- let help = pick_global_flag(program, self.flag);
+ let help = program.pick_flag(self.flag);
if help {
program.user_context.help = true;
}
@@ -75,7 +75,7 @@ where
C: ProgramCollect<Enum = C>,
{
fn setup(self, program: &mut Program<C>) {
- let help = pick_global_flag(program, self.flag);
+ let help = program.pick_flag(self.flag);
if help {
program.stdout_setting.quiet = true;
}
@@ -107,7 +107,7 @@ where
C: ProgramCollect<Enum = C>,
{
fn setup(self, program: &mut Program<C>) {
- let help = pick_global_flag(program, self.flag);
+ let help = program.pick_flag(self.flag);
if help {
program.user_context.confirm = true;
}
diff --git a/mingling/src/setups/picker/structural_renderer.rs b/mingling/src/setups/picker/structural_renderer.rs
index 1fa48fd..91848e4 100644
--- a/mingling/src/setups/picker/structural_renderer.rs
+++ b/mingling/src/setups/picker/structural_renderer.rs
@@ -1,9 +1,6 @@
use mingling_core::{Program, ProgramCollect, setup::ProgramSetup};
-use crate::{
- consts::RENDERER_ARG,
- picker::{pick_global_argument, pick_global_flag},
-};
+use crate::{consts::RENDERER_ARG, picker::PickerHelper};
/// Sets up the structural renderer for the program:
///
@@ -15,7 +12,7 @@ where
C: ProgramCollect<Enum = C>,
{
fn setup(self, program: &mut Program<C>) {
- if let Some(renderer) = pick_global_argument(program, &RENDERER_ARG) {
+ if let Some(renderer) = program.pick_argument(&RENDERER_ARG) {
program.structural_renderer_name = renderer.into();
}
}
@@ -49,27 +46,27 @@ where
{
fn setup(self, program: &mut Program<C>) {
#[cfg(feature = "json_serde_fmt")]
- if pick_global_flag(program, &crate::consts::JSON_FLAG) {
+ if program.pick_flag(&crate::consts::JSON_FLAG) {
program.structural_renderer_name = crate::StructuralRendererSetting::Json;
}
#[cfg(feature = "json_serde_fmt")]
- if pick_global_flag(program, &crate::consts::JSON_PRETTY_FLAG) {
+ if program.pick_flag(&crate::consts::JSON_PRETTY_FLAG) {
program.structural_renderer_name = crate::StructuralRendererSetting::JsonPretty;
}
#[cfg(feature = "yaml_serde_fmt")]
- if pick_global_flag(program, &crate::consts::YAML_FLAG) {
+ if program.pick_flag(&crate::consts::YAML_FLAG) {
program.structural_renderer_name = crate::StructuralRendererSetting::Yaml;
}
#[cfg(feature = "toml_serde_fmt")]
- if pick_global_flag(program, &crate::consts::TOML_FLAG) {
+ if program.pick_flag(&crate::consts::TOML_FLAG) {
program.structural_renderer_name = crate::StructuralRendererSetting::Toml;
}
#[cfg(feature = "ron_serde_fmt")]
- if pick_global_flag(program, &crate::consts::RON_FLAG) {
+ if program.pick_flag(&crate::consts::RON_FLAG) {
program.structural_renderer_name = crate::StructuralRendererSetting::Ron;
}
#[cfg(feature = "ron_serde_fmt")]
- if pick_global_flag(program, &crate::consts::RON_PRETTY_FLAG) {
+ if program.pick_flag(&crate::consts::RON_PRETTY_FLAG) {
program.structural_renderer_name = crate::StructuralRendererSetting::RonPretty;
}
}