aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-10 16:11:04 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-10 16:11:04 +0800
commite9529fac72e8d6bbe466c00b4f60716880c2d03f (patch)
tree60e3fccee0991491e452ff7c49711eee949ee7a6
parentae2885c32f32d19c1becce0118ce51052b55f4a7 (diff)
feat: replace boolean program config with typed enums
Replace boolean flags in `ProgramStdoutSetting` and `ProgramUserContext` with semantic enum types, improving type safety and self-documentation. BREAKING CHANGE: Boolean fields are replaced by enums, e.g. `verbose`/`quiet`/`debug` become `verbosity`, `dry_run`/`force` become `execution`.
-rw-r--r--CHANGELOG.md43
1 files changed, 43 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 75b53f2..369a480 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -361,6 +361,49 @@ None
- `pick_global_argument(program, arg)` → `program.pick_argument(arg)`
- Import `mingling::picker::PickerHelper` instead of `mingling::picker::{pick_global_flag, pick_global_argument}`
+4. **[`core:program`]** **[BREAKING]** Refactored the program configuration settings into typed enums. The previously boolean-based fields in `ProgramStdoutSetting` and `ProgramUserContext` have been replaced with new semantic enum types, improving type safety and self-documentation.
+
+ **`ProgramStdoutSetting` changes:**
+
+ - `error_output: bool` → `error_output: ErrorOutput` — enum with `Show`/`Hide` variants
+ - `render_output: bool` → `render_output: RenderOutput` — enum with `Show`/`Hide` variants
+ - `silence_panic: bool` → `silence_panic: PanicSilence` — enum with `Show`/`Silence` variants
+ - `verbose: bool`, `quiet: bool`, `debug: bool` → `verbosity: Verbosity` — single enum with `Normal`/`Verbose`/`Quiet`/`Debug` variants
+ - `color: bool` → `color: ColorOutput` — enum with `Enabled`/`Disabled` variants
+ - `progress: bool` → `progress: ProgressOutput` — enum with `Enabled`/`Disabled` variants
+
+ **`ProgramUserContext` changes:**
+
+ - `confirm: bool` → `confirmation: ConfirmationMode` — enum with `Confirm`/`Skip` variants
+ - `dry_run: bool`, `force: bool` → `execution: ExecutionMode` — single enum with `Normal`/`DryRun`/`Force` variants
+ - `interactive: bool` → `interaction: InteractionMode` — enum with `Interactive`/`NonInteractive` variants
+ - `assume_yes: bool` → `yes_assumption: YesAssumption` — enum with `None`/`AssumeYes` variants
+
+ **Default values:**
+
+ - `ProgramStdoutSetting::default()`: `ErrorOutput::Show`, `RenderOutput::Show`, `PanicSilence::Show`, `Verbosity::Normal`, `ColorOutput::Enabled`, `ProgressOutput::Enabled`
+ - `ProgramUserContext::default()`: `confirmation: ConfirmationMode::Confirm`, `execution: ExecutionMode::Normal`, `interaction: InteractionMode::NonInteractive`, `yes_assumption: YesAssumption::None`
+
+ All new enum types are defined in `mingling_core::program::config` and re-exported from the `mingling_core` crate root.
+
+ **Migration guide:**
+
+ - `s.error_output = true` → `s.error_output = ErrorOutput::Show` (and `false` → `ErrorOutput::Hide`)
+ - `s.render_output = true` → `s.render_output = RenderOutput::Show`
+ - `s.silence_panic = true` → `s.silence_panic = PanicSilence::Silence`
+ - `s.verbose = true` → `s.verbosity = Verbosity::Verbose`
+ - `s.quiet = true` → `s.verbosity = Verbosity::Quiet`
+ - `s.debug = true` → `s.verbosity = Verbosity::Debug`
+ - `s.color = true` → `s.color = ColorOutput::Enabled`
+ - `s.progress = true` → `s.progress = ProgressOutput::Enabled`
+ - `ctx.confirm = true` → `ctx.confirmation = ConfirmationMode::Skip`
+ - `ctx.dry_run = true` → `ctx.execution = ExecutionMode::DryRun`
+ - `ctx.force = true` → `ctx.execution = ExecutionMode::Force`
+ - `ctx.interactive = true` → `ctx.interaction = InteractionMode::Interactive`
+ - `ctx.assume_yes = true` → `ctx.yes_assumption = YesAssumption::AssumeYes`
+
+ _Behavioral semantics are preserved — the same configuration states are expressible in both the old boolean form and the new enum form, but the typed enums eliminate impossible states (e.g., both `verbose` and `quiet` set simultaneously) and make the intent of each setting explicit through named variants._
+
---
### Release 0.3.0 (2026-07-27)