From bf96f8292c0e9818c8b5fc8713ca7506e4338a49 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 6 May 2026 03:38:32 +0900 Subject: refactor(console): add write macros and migrate commands to use them --- crates/mozart/src/commands/require.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'crates/mozart/src/commands/require.rs') diff --git a/crates/mozart/src/commands/require.rs b/crates/mozart/src/commands/require.rs index 828474d..150a003 100644 --- a/crates/mozart/src/commands/require.rs +++ b/crates/mozart/src/commands/require.rs @@ -1,7 +1,7 @@ use clap::Args; use indexmap::{IndexMap, IndexSet}; -use mozart_core::console::Verbosity; use mozart_core::console_format; +use mozart_core::console_writeln; use mozart_core::package::{self, Stability}; use mozart_core::validation; use mozart_registry::lockfile; @@ -462,11 +462,11 @@ pub async fn execute( anyhow::bail!("Invalid package name: \"{name}\""); } - console.write_stdout( + console_writeln!( + console, &console_format!( "Using version constraint for {name} from Packagist..." ), - Verbosity::Normal, ); let versions = packagist::fetch_package_versions(&name, &repo_cache).await?; @@ -489,9 +489,9 @@ pub async fn execute( ) }; - console.write_stdout( + console_writeln!( + console, &console_format!("Using version {constraint} for {name}"), - Verbosity::Normal, ); (name, constraint) @@ -543,16 +543,16 @@ pub async fn execute( }; if let Some(existing) = target.get(name) { - console.write_stdout( + console_writeln!( + console, &console_format!( "Updating {name} from {existing} to {constraint} in {section_name}" ), - Verbosity::Normal, ); } else { - console.write_stdout( + console_writeln!( + console, &console_format!("Adding {name} ({constraint}) to {section_name}"), - Verbosity::Normal, ); } @@ -578,9 +578,9 @@ pub async fn execute( // Write back composer.json (unless --dry-run) if args.dry_run { - console.write_stdout( + console_writeln!( + console, &console_format!("Dry run: composer.json not modified."), - Verbosity::Normal, ); } else { package::write_to_file(&raw, &composer_path)?; @@ -588,11 +588,11 @@ pub async fn execute( // Handle --no-update: skip resolution entirely if args.no_update { - console.write_stdout( + console_writeln!( + console, &console_format!( "Not updating dependencies, only modifying composer.json." ), - Verbosity::Normal, ); return Ok(()); } -- cgit v1.3.1