diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-22 22:53:09 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-22 22:53:22 +0900 |
| commit | 6f3802fd9f39c4e5847d130b4417b5cdfb66972d (patch) | |
| tree | 166cca2cf0645d280bfa376a513a049c70241dea /crates/mozart/src/commands/search.rs | |
| parent | 1d33728151b282949e7e14646e722d7775de4453 (diff) | |
| download | php-mozart-6f3802fd9f39c4e5847d130b4417b5cdfb66972d.tar.gz php-mozart-6f3802fd9f39c4e5847d130b4417b5cdfb66972d.tar.zst php-mozart-6f3802fd9f39c4e5847d130b4417b5cdfb66972d.zip | |
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!("<info>text {name}</info>")`. 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 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart/src/commands/search.rs')
| -rw-r--r-- | crates/mozart/src/commands/search.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/mozart/src/commands/search.rs b/crates/mozart/src/commands/search.rs index f145460..06e67c9 100644 --- a/crates/mozart/src/commands/search.rs +++ b/crates/mozart/src/commands/search.rs @@ -1,4 +1,5 @@ use clap::Args; +use mozart_core::console_format; use mozart_registry::packagist::SearchResult; #[derive(Args)] @@ -75,9 +76,9 @@ pub async fn execute( if !matches!(format, "text" | "json") { eprintln!( "{}", - mozart_core::console::error(&format!( - "Unsupported format \"{format}\". See help for supported formats." - )) + console_format!( + "<error>Unsupported format \"{format}\". See help for supported formats.</error>" + ) ); std::process::exit(1); } @@ -107,7 +108,7 @@ pub async fn execute( if results.is_empty() { eprintln!( "{}", - mozart_core::console::warning(&format!("No packages found for \"{query}\"")) + console_format!("<warning>No packages found for \"{query}\"</warning>") ); return Ok(()); } @@ -130,13 +131,9 @@ pub async fn execute( println!( "{} {} {}", - mozart_core::console::info(&format!( - "{:<width$}", - result.name, - width = name_width - )), - mozart_core::console::comment(&dl_str), - mozart_core::console::comment(&fav_str), + console_format!("<info>{:<width$}</info>", result.name, width = name_width), + console_format!("<comment>{}</comment>", dl_str), + console_format!("<comment>{}</comment>", fav_str), ); if !result.description.is_empty() { println!(" {}", result.description); |
