aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-14 17:47:15 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-14 18:02:09 +0800
commit9c8fe13c2629a4318bd12815c07cef1371ba85a2 (patch)
tree9e9af625832a1f872f5523dbf9d9730af0ef90c8 /mingling_core/src
parentf3c134615c56dc7372e47a216dddca72250a3308 (diff)
feat(core): move config types to public config module
Refactor program configuration types into a dedicated public `config` module under `mingling_core`, making `StructuralRendererSetting` accessible via `mingling_core::config` instead of the crate root. Update all internal references and setup modules to use the new `config::` path convention.
Diffstat (limited to 'mingling_core/src')
-rw-r--r--mingling_core/src/program.rs28
-rw-r--r--mingling_core/src/program/collection.rs2
-rw-r--r--mingling_core/src/program/collection/mock.rs2
-rw-r--r--mingling_core/src/program/config.rs24
-rw-r--r--mingling_core/src/program/hook.rs2
-rw-r--r--mingling_core/src/program/once_exec.rs4
-rw-r--r--mingling_core/src/renderer/structural.rs2
7 files changed, 47 insertions, 17 deletions
diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs
index 3c4212c..86e3e83 100644
--- a/mingling_core/src/program.rs
+++ b/mingling_core/src/program.rs
@@ -2,41 +2,47 @@
#[cfg(not(windows))]
use std::env;
+#[cfg(feature = "structural_renderer")]
+use crate::config::StructuralRendererSetting;
use crate::{
- AnyOutput, GlobalResContainer, asset::dispatcher::Dispatcher, error::ChainProcessError,
+ AnyOutput, GlobalResContainer,
+ asset::dispatcher::Dispatcher,
+ config::{ProgramStdoutSetting, ProgramUserContext},
+ error::ChainProcessError,
hook::ProgramHook,
};
+pub mod config;
+
#[doc(hidden)]
pub mod error;
+
#[doc(hidden)]
pub mod exec;
-#[doc(hidden)]
-pub mod setup;
pub mod hook;
-mod collection;
-pub use collection::*;
-
-mod once_exec;
-
#[cfg(feature = "repl")]
#[doc(hidden)]
pub mod repl_exec;
+#[doc(hidden)]
+pub mod setup;
+
+mod collection;
+pub use collection::*;
+
mod single_instance;
pub use single_instance::*;
-mod config;
-pub use config::*;
-
mod flag;
pub use flag::*;
mod string_vec;
pub use string_vec::*;
+mod once_exec;
+
/// Program, used to define the behavior of the entire command-line program
#[derive(Default)]
pub struct Program<C>
diff --git a/mingling_core/src/program/collection.rs b/mingling_core/src/program/collection.rs
index 0a37106..2b3e9ec 100644
--- a/mingling_core/src/program/collection.rs
+++ b/mingling_core/src/program/collection.rs
@@ -8,7 +8,7 @@ use crate::Dispatcher;
use crate::{AnyOutput, ChainProcess, Grouped, RenderResult};
#[cfg(feature = "structural_renderer")]
-use crate::{StructuralRendererSetting, error::StructuralRendererSerializeError};
+use crate::{config::StructuralRendererSetting, error::StructuralRendererSerializeError};
#[cfg(feature = "comp")]
use crate::{ShellContext, Suggest};
diff --git a/mingling_core/src/program/collection/mock.rs b/mingling_core/src/program/collection/mock.rs
index 634d529..6b4406e 100644
--- a/mingling_core/src/program/collection/mock.rs
+++ b/mingling_core/src/program/collection/mock.rs
@@ -10,7 +10,7 @@ use crate::Dispatcher;
use crate::{ShellContext, Suggest};
#[cfg(feature = "structural_renderer")]
-use crate::{StructuralRendererSetting, error::StructuralRendererSerializeError};
+use crate::{config::StructuralRendererSetting, error::StructuralRendererSerializeError};
#[cfg(feature = "structural_renderer")]
use serde::Serialize;
diff --git a/mingling_core/src/program/config.rs b/mingling_core/src/program/config.rs
index 86b8c23..dae3f0a 100644
--- a/mingling_core/src/program/config.rs
+++ b/mingling_core/src/program/config.rs
@@ -1,4 +1,28 @@
// Doc Not Optimize
+
+//! Config module for program output settings and user context.
+//!
+//! This module provides configuration types and settings for controlling
+//! how the program outputs errors, rendered results, panic messages,
+//! verbosity levels, colors, progress indicators, and other user-defined
+//! context values used throughout the program lifecycle.
+//!
+//! The module includes the following items:
+//! - [`ErrorOutput`]: Output mode for error messages.
+//! - [`RenderOutput`]: Output mode for rendered results.
+//! - [`PanicSilence`]: Panic message handling.
+//! - [`Verbosity`]: Verbosity level for program output.
+//! - [`ColorOutput`]: Color output mode.
+//! - [`ProgressOutput`]: Progress indicator mode.
+//! - [`ProgramStdoutSetting`]: Program stdout settings.
+//! - [`ClapHelpPrintBehaviour`]: Behavior when Clap Dispatcher outputs help information.
+//! - [`ConfirmationMode`]: Confirmation mode for user prompts.
+//! - [`ExecutionMode`]: Execution mode.
+//! - [`InteractionMode`]: Interaction mode.
+//! - [`YesAssumption`]: Yes assumption mode for prompts.
+//! - [`ProgramUserContext`]: Program user context.
+//! - [`StructuralRendererSetting`]: Settings for the structural renderer output format.
+
/// Output mode for error messages
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ErrorOutput {
diff --git a/mingling_core/src/program/hook.rs b/mingling_core/src/program/hook.rs
index cb8e4e1..8fd2ba1 100644
--- a/mingling_core/src/program/hook.rs
+++ b/mingling_core/src/program/hook.rs
@@ -768,7 +768,7 @@ mod tests {
#[cfg(feature = "structural_renderer")]
fn structural_render(
_any: crate::AnyOutput<Self>,
- _setting: &crate::StructuralRendererSetting,
+ _setting: &crate::config::StructuralRendererSetting,
) -> Result<crate::RenderResult, crate::error::StructuralRendererSerializeError> {
unreachable!()
}
diff --git a/mingling_core/src/program/once_exec.rs b/mingling_core/src/program/once_exec.rs
index b1fba36..e9927b5 100644
--- a/mingling_core/src/program/once_exec.rs
+++ b/mingling_core/src/program/once_exec.rs
@@ -99,7 +99,7 @@ where
// Read exit code
// Render result
- if stdout_setting.render_output == crate::RenderOutput::Show {
+ if stdout_setting.render_output == crate::config::RenderOutput::Show {
result.std_print();
}
@@ -163,7 +163,7 @@ where
.unwrap();
#[cfg(not(panic = "abort"))]
- if program.stdout_setting.silence_panic == super::PanicSilence::Silence {
+ if program.stdout_setting.silence_panic == super::config::PanicSilence::Silence {
std::panic::set_hook(Box::new(|_| {}));
}
diff --git a/mingling_core/src/renderer/structural.rs b/mingling_core/src/renderer/structural.rs
index aeb637f..b2c1f8a 100644
--- a/mingling_core/src/renderer/structural.rs
+++ b/mingling_core/src/renderer/structural.rs
@@ -1,6 +1,6 @@
// Doc Not Optimize
use crate::{
- ProgramCollect, RenderResult, StructuralRendererSetting,
+ ProgramCollect, RenderResult, config::StructuralRendererSetting,
renderer::structural::error::StructuralRendererSerializeError,
};
use serde::Serialize;