aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands/config.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-23 15:11:36 +0900
committernsfisis <nsfisis@gmail.com>2026-02-23 15:11:36 +0900
commitd6e0c6d34449224ac3687daf551a0acfd15cee32 (patch)
treed6767718ad566542d4770d4688d9961e0f74ea3d /crates/mozart/src/commands/config.rs
parent7e45efd8a1f488b1a684f9efe31ff39009fc9e54 (diff)
downloadphp-mozart-d6e0c6d34449224ac3687daf551a0acfd15cee32.tar.gz
php-mozart-d6e0c6d34449224ac3687daf551a0acfd15cee32.tar.zst
php-mozart-d6e0c6d34449224ac3687daf551a0acfd15cee32.zip
refactor(cli): route command output through Console abstraction
Replace direct println\!/eprintln\! calls with console.write(), console.info(), and console.write_stdout() across all command handlers to respect verbosity settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/config.rs')
-rw-r--r--crates/mozart/src/commands/config.rs28
1 files changed, 18 insertions, 10 deletions
diff --git a/crates/mozart/src/commands/config.rs b/crates/mozart/src/commands/config.rs
index df31f8d..3947afd 100644
--- a/crates/mozart/src/commands/config.rs
+++ b/crates/mozart/src/commands/config.rs
@@ -504,7 +504,7 @@ fn load_config_section(
pub async fn execute(
args: &ConfigArgs,
cli: &super::Cli,
- _console: &mozart_core::console::Console,
+ console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
// 1. Handle --editor mode
if args.editor {
@@ -526,7 +526,7 @@ pub async fn execute(
}
// 4b. Read mode
- execute_read(args, cli, &config_file_path)
+ execute_read(args, cli, &config_file_path, console)
}
// ─── execute_editor() ────────────────────────────────────────────────────────
@@ -895,6 +895,7 @@ fn execute_read(
args: &ConfigArgs,
cli: &super::Cli,
config_file_path: &Path,
+ console: &mozart_core::console::Console,
) -> anyhow::Result<()> {
// Build the effective config for config-section keys.
let mut config = ComposerConfig::defaults();
@@ -934,20 +935,23 @@ fn execute_read(
if args.list {
for (key, value) in &config.values {
- println!("[{}] {}", key, render_value(value));
+ console.write_stdout(
+ &format!("[{}] {}", key, render_value(value)),
+ mozart_core::console::Verbosity::Quiet,
+ );
}
return Ok(());
}
match &args.setting_key {
None => {
- eprintln!(
+ console.error(&format!(
"{}",
mozart_core::console::error(
"No command specified. Use --list to show all config values, \
- or provide a setting key."
+ or provide a setting key."
)
- );
+ ));
return Err(mozart_core::exit_code::bail_silent(
mozart_core::exit_code::GENERAL_ERROR,
));
@@ -959,7 +963,10 @@ 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) {
- println!("{}", render_value(entry));
+ console.write_stdout(
+ &render_value(entry),
+ mozart_core::console::Verbosity::Quiet,
+ );
return Ok(());
}
}
@@ -971,7 +978,7 @@ 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) {
- println!("{}", render_value(v));
+ console.write_stdout(&render_value(v), mozart_core::console::Verbosity::Quiet);
return Ok(());
}
return Err(anyhow!("Setting \"{}\" does not exist.", key));
@@ -981,7 +988,7 @@ 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()) {
- println!("{}", render_value(v));
+ console.write_stdout(&render_value(v), mozart_core::console::Verbosity::Quiet);
return Ok(());
}
// Fall through to config section lookup
@@ -990,7 +997,8 @@ fn execute_read(
// 4. Standard config key lookup
match config.get(key) {
Some(value) => {
- println!("{}", render_value(value));
+ console
+ .write_stdout(&render_value(value), mozart_core::console::Verbosity::Quiet);
}
None => {
return Err(anyhow!("Setting \"{}\" does not exist.", key));