From 6f3802fd9f39c4e5847d130b4417b5cdfb66972d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 22 Feb 2026 22:53:09 +0900 Subject: refactor(console): add console_format! proc macro and migrate all commands Introduce a Symfony Console-style tag macro that replaces verbose patterns like `console::info(&format!("text {name}"))` with `console_format!("text {name}")`. Supports all 6 tag types (info, comment, error, question, highlight, warning) with format argument distribution across multiple tagged segments. Co-Authored-By: Claude Opus 4.6 --- crates/mozart/src/commands/suggests.rs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'crates/mozart/src/commands/suggests.rs') diff --git a/crates/mozart/src/commands/suggests.rs b/crates/mozart/src/commands/suggests.rs index b61e1c3..3fb2f00 100644 --- a/crates/mozart/src/commands/suggests.rs +++ b/crates/mozart/src/commands/suggests.rs @@ -1,5 +1,6 @@ use clap::Args; use mozart_core::console; +use mozart_core::console_format; use std::collections::{BTreeMap, HashMap, HashSet}; use std::path::{Path, PathBuf}; @@ -135,8 +136,8 @@ pub async fn execute( if diff > 0 { println!( "{} by transitive dependencies can be shown with {}", - console::info(&format!("{diff} additional suggestions")), - console::info("--all"), + console_format!("{diff} additional suggestions"), + console_format!("--all"), ); } } @@ -435,7 +436,7 @@ fn render_list(suggestions: &[&Suggestion]) { targets.sort_unstable(); targets.dedup(); for t in targets { - println!("{}", console::info(t)); + println!("{}", console_format!("{}", t)); } } @@ -446,13 +447,19 @@ fn render_by_package(suggestions: &[&Suggestion]) { grouped.entry(s.source.as_str()).or_default().push(s); } for (source, items) in &grouped { - println!("{} suggests:", console::comment(source)); + println!( + "{}", + console_format!("{} suggests:", source) + ); for s in items { let reason = sanitize_reason(&s.reason); if reason.is_empty() { - println!(" - {}", console::info(&s.target)); + println!("{}", console_format!(" - {}", &s.target)); } else { - println!(" - {}: {}", console::info(&s.target), reason); + println!( + "{}", + console_format!(" - {}: {}", &s.target, reason) + ); } } println!(); @@ -466,13 +473,19 @@ fn render_by_suggestion(suggestions: &[&Suggestion]) { grouped.entry(s.target.as_str()).or_default().push(s); } for (target, items) in &grouped { - println!("{} is suggested by:", console::info(target)); + println!( + "{}", + console_format!("{} is suggested by:", target) + ); for s in items { let reason = sanitize_reason(&s.reason); if reason.is_empty() { - println!(" - {}", console::comment(&s.source)); + println!("{}", console_format!(" - {}", &s.source)); } else { - println!(" - {}: {}", console::comment(&s.source), reason); + println!( + "{}", + console_format!(" - {}: {}", &s.source, reason) + ); } } println!(); -- cgit v1.3.1