diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-13 07:28:02 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-13 07:28:02 +0800 |
| commit | 95c6b979ca399671eed8bf9c72f53cfe5d46f431 (patch) | |
| tree | 8225b39bee4ad3b7ebc8a36ab978d1329f667eb8 /mingling/src/setups/basic.rs | |
| parent | fef888b75b2544765aa06808c14490a2af827313 (diff) | |
Migrate exit code control to resource-based system
Diffstat (limited to 'mingling/src/setups/basic.rs')
| -rw-r--r-- | mingling/src/setups/basic.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mingling/src/setups/basic.rs b/mingling/src/setups/basic.rs new file mode 100644 index 0000000..6164c64 --- /dev/null +++ b/mingling/src/setups/basic.rs @@ -0,0 +1,28 @@ +use mingling_core::{Program, ProgramCollect, setup::ProgramSetup}; + +/// Performs basic program initialization: +/// +/// - Collects `--quiet` flag to control message rendering +/// - Collects `--help` flag to enable help mode +/// - Collects `--confirm` flag to skip user confirmation +pub struct BasicProgramSetup; + +impl<C> ProgramSetup<C> for BasicProgramSetup +where + C: ProgramCollect<Enum = C>, +{ + fn setup(&mut self, program: &mut Program<C>) { + program.global_flag(["--quiet", "-q"], |p| { + p.stdout_setting.render_output = false; + p.stdout_setting.error_output = false; + }); + + program.global_flag(["--help", "-h"], |p| { + p.user_context.help = true; + }); + + program.global_flag(["--confirm", "-C"], |p| { + p.user_context.confirm = true; + }); + } +} |
