From d1a74ce57e5be72436376a829e9c7e1e7c1c561b Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 26 Jun 2026 06:27:16 +0800 Subject: refactor(general_renderer): rename to structural_renderer --- mingling/src/setups/structural_renderer.rs | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 mingling/src/setups/structural_renderer.rs (limited to 'mingling/src/setups/structural_renderer.rs') diff --git a/mingling/src/setups/structural_renderer.rs b/mingling/src/setups/structural_renderer.rs new file mode 100644 index 0000000..af3ed91 --- /dev/null +++ b/mingling/src/setups/structural_renderer.rs @@ -0,0 +1,61 @@ +use mingling_core::{Program, ProgramCollect, setup::ProgramSetup}; + +/// Sets up the structural renderer for the program: +/// +/// - Adds a `--renderer` global argument to specify the renderer type +pub struct StructuralRendererSimpleSetup; + +impl ProgramSetup for StructuralRendererSimpleSetup +where + C: ProgramCollect, +{ + fn setup(self, program: &mut Program) { + program.global_argument("--renderer", |p, renderer| { + p.structural_renderer_name = renderer.into(); + }); + } +} + +/// Sets up the structural renderer for the program: +/// +/// - Adds global flags to specify the renderer type: +/// * `--json` for JSON output +/// * `--json-pretty` for pretty-printed JSON output +/// * `--yaml` for YAML output +/// * `--toml` for TOML output +/// * `--ron` for RON output +/// * `--ron-pretty` for pretty-printed RON output +pub struct StructuralRendererSetup; + +impl ProgramSetup for StructuralRendererSetup +where + C: ProgramCollect, +{ + #[allow(unused_variables)] + fn setup(self, program: &mut Program) { + #[cfg(feature = "json_serde_fmt")] + program.global_flag("--json", |p| { + p.structural_renderer_name = crate::StructuralRendererSetting::Json; + }); + #[cfg(feature = "json_serde_fmt")] + program.global_flag("--json-pretty", |p| { + p.structural_renderer_name = crate::StructuralRendererSetting::JsonPretty; + }); + #[cfg(feature = "yaml_serde_fmt")] + program.global_flag("--yaml", |p| { + p.structural_renderer_name = crate::StructuralRendererSetting::Yaml; + }); + #[cfg(feature = "toml_serde_fmt")] + program.global_flag("--toml", |p| { + p.structural_renderer_name = crate::StructuralRendererSetting::Toml; + }); + #[cfg(feature = "ron_serde_fmt")] + program.global_flag("--ron", |p| { + p.structural_renderer_name = crate::StructuralRendererSetting::Ron; + }); + #[cfg(feature = "ron_serde_fmt")] + program.global_flag("--ron-pretty", |p| { + p.structural_renderer_name = crate::StructuralRendererSetting::RonPretty; + }); + } +} -- cgit