diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-06 03:38:32 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-06 04:05:13 +0900 |
| commit | bf96f8292c0e9818c8b5fc8713ca7506e4338a49 (patch) | |
| tree | 61ddecc119ee0ae344eabdb9c0f784cdb3461a44 /crates/mozart/src/commands/config.rs | |
| parent | b97e34358be5df05a3db9f5f3ef1502eaa94b1c0 (diff) | |
| download | php-mozart-bf96f8292c0e9818c8b5fc8713ca7506e4338a49.tar.gz php-mozart-bf96f8292c0e9818c8b5fc8713ca7506e4338a49.tar.zst php-mozart-bf96f8292c0e9818c8b5fc8713ca7506e4338a49.zip | |
refactor(console): add write macros and migrate commands to use them
Diffstat (limited to 'crates/mozart/src/commands/config.rs')
| -rw-r--r-- | crates/mozart/src/commands/config.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/crates/mozart/src/commands/config.rs b/crates/mozart/src/commands/config.rs index 274dcde..ebc8f30 100644 --- a/crates/mozart/src/commands/config.rs +++ b/crates/mozart/src/commands/config.rs @@ -1,5 +1,8 @@ use anyhow::anyhow; use clap::Args; +use mozart_core::config::resolve_references; +use mozart_core::console_writeln; +use mozart_core::factory::create_config; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; @@ -60,9 +63,6 @@ pub struct ConfigArgs { pub source: bool, } -use mozart_core::config::resolve_references; -use mozart_core::factory::create_config; - /// Classification of config key value types for validation and normalization. #[derive(Debug)] enum ConfigValueType { @@ -776,7 +776,8 @@ fn execute_read( if args.list { for (key, value) in config.entries() { - console.write_stdout( + console_writeln!( + console, &format!("[{}] {}", key, render_value(&value)), mozart_core::console::Verbosity::Quiet, ); @@ -804,7 +805,8 @@ fn execute_read( if let Some(repos) = raw["repositories"].as_array() { for entry in repos { if entry.get("name").and_then(|n| n.as_str()) == Some(repo_name) { - console.write_stdout( + console_writeln!( + console, &render_value(entry), mozart_core::console::Verbosity::Quiet, ); @@ -819,7 +821,11 @@ fn execute_read( if key.starts_with("extra.") || key.starts_with("suggest.") { let raw = read_json_file(config_file_path, args.global)?; if let Some(v) = get_nested(&raw, key) { - console.write_stdout(&render_value(v), mozart_core::console::Verbosity::Quiet); + console_writeln!( + console, + &render_value(v), + mozart_core::console::Verbosity::Quiet, + ); return Ok(()); } return Err(anyhow!("Setting \"{}\" does not exist.", key)); @@ -829,7 +835,11 @@ fn execute_read( if CONFIGURABLE_PACKAGE_PROPERTIES.contains(&key.as_str()) { let raw = read_json_file(config_file_path, args.global)?; if let Some(v) = raw.get(key.as_str()) { - console.write_stdout(&render_value(v), mozart_core::console::Verbosity::Quiet); + console_writeln!( + console, + &render_value(v), + mozart_core::console::Verbosity::Quiet, + ); return Ok(()); } // Fall through to config section lookup @@ -838,7 +848,8 @@ fn execute_read( // 4. Standard config key lookup match config.get(key) { Some(value) => { - console.write_stdout( + console_writeln!( + console, &render_value(&value), mozart_core::console::Verbosity::Quiet, ); |
