aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-06 04:02:24 +0900
committernsfisis <nsfisis@gmail.com>2026-05-06 04:05:13 +0900
commit2bc47940be9359e34cfe50c64fe76234999bc716 (patch)
tree52859450ba8704df79d22917aa132fc5b3a702a6 /crates/mozart
parentbf96f8292c0e9818c8b5fc8713ca7506e4338a49 (diff)
downloadphp-mozart-2bc47940be9359e34cfe50c64fe76234999bc716.tar.gz
php-mozart-2bc47940be9359e34cfe50c64fe76234999bc716.tar.zst
php-mozart-2bc47940be9359e34cfe50c64fe76234999bc716.zip
refactor(console): rename color helpers and migrate call sites to console_format!
The six tag-style color functions (info, comment, error, question, highlight, warning) are pub only so that console_format! can call them from generated code; they are not part of the public API. Rename them to __format_*_message to make that intent visible, add a doc-comment saying not to call them directly, and replace every remaining direct call site with console_format!. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'crates/mozart')
-rw-r--r--crates/mozart/src/commands/audit.rs16
-rw-r--r--crates/mozart/src/commands/check_platform_reqs.rs40
-rw-r--r--crates/mozart/src/commands/config.rs11
-rw-r--r--crates/mozart/src/commands/dependency.rs16
-rw-r--r--crates/mozart/src/commands/dump_autoload.rs8
-rw-r--r--crates/mozart/src/commands/install.rs11
-rw-r--r--crates/mozart/src/commands/licenses.rs10
-rw-r--r--crates/mozart/src/commands/outdated.rs17
-rw-r--r--crates/mozart/src/commands/update.rs11
-rw-r--r--crates/mozart/src/commands/validate.rs20
10 files changed, 63 insertions, 97 deletions
diff --git a/crates/mozart/src/commands/audit.rs b/crates/mozart/src/commands/audit.rs
index f9da344..5c0d46c 100644
--- a/crates/mozart/src/commands/audit.rs
+++ b/crates/mozart/src/commands/audit.rs
@@ -1,4 +1,5 @@
use clap::Args;
+use mozart_core::console_format;
use mozart_core::console_writeln;
use mozart_core::console_writeln_error;
use mozart_registry::packagist::SecurityAdvisory;
@@ -376,9 +377,8 @@ fn detect_abandoned(packages: &[PackageEntry]) -> Vec<AbandonedPackage> {
fn render_table(result: &AuditResult, console: &mozart_core::console::Console) {
if result.total_advisory_count == 0 && result.abandoned.is_empty() {
- console.info(&format!(
- "{}",
- mozart_core::console::info("No security vulnerability advisories found.")
+ console.info(&console_format!(
+ "<info>No security vulnerability advisories found.</info>"
));
return;
}
@@ -393,10 +393,7 @@ fn render_table(result: &AuditResult, console: &mozart_core::console::Console) {
"Found {} security vulnerability {} affecting {} package(s):",
result.total_advisory_count, advisory_word, result.affected_package_count
);
- console_writeln_error!(
- console,
- &format!("{}", mozart_core::console::highlight(&header)),
- );
+ console_writeln_error!(console, &console_format!("<highlight>{header}</highlight>"),);
console_writeln_error!(console, "");
for advisories in result.advisories.values() {
@@ -450,10 +447,7 @@ fn render_table(result: &AuditResult, console: &mozart_core::console::Console) {
if !result.abandoned.is_empty() {
let header = format!("Found {} abandoned package(s):", result.abandoned.len());
- console_writeln_error!(
- console,
- &format!("{}", mozart_core::console::highlight(&header)),
- );
+ console_writeln_error!(console, &console_format!("<highlight>{header}</highlight>"),);
console_writeln_error!(console, "");
let name_width = 20usize;
diff --git a/crates/mozart/src/commands/check_platform_reqs.rs b/crates/mozart/src/commands/check_platform_reqs.rs
index e96610e..a5856ca 100644
--- a/crates/mozart/src/commands/check_platform_reqs.rs
+++ b/crates/mozart/src/commands/check_platform_reqs.rs
@@ -1,5 +1,6 @@
use clap::Args;
use mozart_core::console::Console;
+use mozart_core::console_format;
use mozart_core::console_writeln;
use mozart_core::console_writeln_error;
use std::collections::BTreeMap;
@@ -143,12 +144,9 @@ fn collect_requirements(
// Fall through to lock file with a warning
console_writeln_error!(
console,
- &format!(
- "{}",
- mozart_core::console::warning(&format!(
- "No vendor dir present, checking {}platform requirements from the lock file",
- dev_text
- ))
+ &console_format!(
+ "<warning>No vendor dir present, checking {}platform requirements from the lock file</warning>",
+ dev_text
),
);
if !lock_path.exists() {
@@ -168,12 +166,9 @@ fn collect_requirements(
// Fallback: read from lock file
console_writeln_error!(
console,
- &format!(
- "{}",
- mozart_core::console::warning(&format!(
- "No vendor dir present, checking {}platform requirements from the lock file",
- dev_text
- ))
+ &console_format!(
+ "<warning>No vendor dir present, checking {}platform requirements from the lock file</warning>",
+ dev_text
),
);
collect_from_lock(&lock_path, args.no_dev, &mut requirements)?;
@@ -365,11 +360,8 @@ fn render_text(results: &[CheckResult], console: &Console) {
CheckStatus::Success => {
console_writeln!(
console,
- &format!(
- "{} {} {}",
- mozart_core::console::info(&padded_name),
- mozart_core::console::comment(&padded_version),
- mozart_core::console::info("success"),
+ &console_format!(
+ "<info>{padded_name}</info> <comment>{padded_version}</comment> <info>success</info>"
),
);
}
@@ -381,11 +373,8 @@ fn render_text(results: &[CheckResult], console: &Console) {
.unwrap_or(("", ""));
console_writeln!(
console,
- &format!(
- "{} {} {} requires {} ({})",
- mozart_core::console::comment(&padded_name),
- mozart_core::console::comment(&padded_version),
- mozart_core::console::error("failed"),
+ &console_format!(
+ "<comment>{padded_name}</comment> <comment>{padded_version}</comment> <error>failed</error> requires {} ({})",
provider,
constraint,
),
@@ -399,11 +388,8 @@ fn render_text(results: &[CheckResult], console: &Console) {
.unwrap_or(("*", ""));
console_writeln!(
console,
- &format!(
- "{} {} {} requires {} ({})",
- mozart_core::console::comment(&padded_name),
- mozart_core::console::comment(&padded_version),
- mozart_core::console::error("missing"),
+ &console_format!(
+ "<comment>{padded_name}</comment> <comment>{padded_version}</comment> <error>missing</error> requires {} ({})",
provider,
constraint,
),
diff --git a/crates/mozart/src/commands/config.rs b/crates/mozart/src/commands/config.rs
index ebc8f30..64cf209 100644
--- a/crates/mozart/src/commands/config.rs
+++ b/crates/mozart/src/commands/config.rs
@@ -787,13 +787,10 @@ fn execute_read(
match &args.setting_key {
None => {
- console.error(&format!(
- "{}",
- mozart_core::console::error(
- "No command specified. Use --list to show all config values, \
- or provide a setting key."
- )
- ));
+ console.error(
+ "No command specified. Use --list to show all config values, \
+ or provide a setting key.",
+ );
return Err(mozart_core::exit_code::bail_silent(
mozart_core::exit_code::GENERAL_ERROR,
));
diff --git a/crates/mozart/src/commands/dependency.rs b/crates/mozart/src/commands/dependency.rs
index d0f2d48..8b84fe4 100644
--- a/crates/mozart/src/commands/dependency.rs
+++ b/crates/mozart/src/commands/dependency.rs
@@ -650,7 +650,7 @@ pub fn print_table(results: &[DependencyResult], console: &mozart_core::console:
if results.is_empty() {
console_writeln!(
console,
- &format!("{}", mozart_core::console::info("No relationships found.")),
+ &console_format!("<info>No relationships found.</info>"),
);
return;
}
@@ -685,10 +685,10 @@ pub fn print_table(results: &[DependencyResult], console: &mozart_core::console:
console,
&format!(
"{:<name_w$} {:<ver_w$} {:<desc_w$} {}",
- mozart_core::console::info(&r.package_name),
- mozart_core::console::comment(&r.package_version),
+ console_format!("<info>{}</info>", r.package_name),
+ console_format!("<comment>{}</comment>", r.package_version),
r.link_description,
- mozart_core::console::comment(&r.link_constraint),
+ console_format!("<comment>{}</comment>", r.link_constraint),
name_w = name_w,
ver_w = ver_w,
desc_w = desc_w,
@@ -714,7 +714,7 @@ pub fn print_tree(
if results.is_empty() && depth == 0 {
console_writeln!(
console,
- &format!("{}", mozart_core::console::info("No relationships found.")),
+ &console_format!("<info>No relationships found.</info>"),
);
return;
}
@@ -729,10 +729,10 @@ pub fn print_tree(
&format!(
"{}{:<} {} {} {}",
prefix,
- mozart_core::console::info(&r.package_name),
- mozart_core::console::comment(&r.package_version),
+ console_format!("<info>{}</info>", r.package_name),
+ console_format!("<comment>{}</comment>", r.package_version),
r.link_description,
- mozart_core::console::comment(&r.link_constraint),
+ console_format!("<comment>{}</comment>", r.link_constraint),
),
);
diff --git a/crates/mozart/src/commands/dump_autoload.rs b/crates/mozart/src/commands/dump_autoload.rs
index a86cf21..076d72d 100644
--- a/crates/mozart/src/commands/dump_autoload.rs
+++ b/crates/mozart/src/commands/dump_autoload.rs
@@ -1,4 +1,5 @@
use clap::Args;
+use mozart_core::console_format;
#[derive(Args)]
pub struct DumpAutoloadArgs {
@@ -67,11 +68,8 @@ pub async fn execute(
let install_path = vendor_composer_dir.join(rel);
if !install_path.exists() {
missing_dependencies = true;
- console.info(&format!(
- "{}",
- mozart_core::console::warning(
- "Not all dependencies are installed. Make sure to run a \"composer install\" to install missing dependencies"
- )
+ console.info(&console_format!(
+ "<warning>Not all dependencies are installed. Make sure to run a \"composer install\" to install missing dependencies</warning>"
));
break;
}
diff --git a/crates/mozart/src/commands/install.rs b/crates/mozart/src/commands/install.rs
index 91d73e0..428c5cc 100644
--- a/crates/mozart/src/commands/install.rs
+++ b/crates/mozart/src/commands/install.rs
@@ -987,13 +987,10 @@ fn warn_platform_requirements(
if is_platform_package(req_name) {
let lower = req_name.to_lowercase();
if !ignored_set.contains(&lower) {
- console.info(&format!(
- "{}",
- console::warning(&format!(
- "Platform requirement {req_name} {req_constraint} (required by {}) \
- has not been verified. Platform detection is not yet fully implemented.",
- pkg.name
- ))
+ console.info(&console_format!(
+ "<warning>Platform requirement {req_name} {req_constraint} (required by {}) \
+ has not been verified. Platform detection is not yet fully implemented.</warning>",
+ pkg.name
));
}
}
diff --git a/crates/mozart/src/commands/licenses.rs b/crates/mozart/src/commands/licenses.rs
index dc232e9..7515b32 100644
--- a/crates/mozart/src/commands/licenses.rs
+++ b/crates/mozart/src/commands/licenses.rs
@@ -1,6 +1,7 @@
use clap::Args;
use indexmap::IndexSet;
use mozart_core::console::Console;
+use mozart_core::console_format;
use mozart_core::console_writeln;
use serde::Serialize;
use std::path::Path;
@@ -198,18 +199,15 @@ fn render_text(
};
console_writeln!(
console,
- &format!("Name: {}", mozart_core::console::comment(root_name)),
+ &console_format!("Name: <comment>{root_name}</comment>"),
);
console_writeln!(
console,
- &format!("Version: {}", mozart_core::console::comment(root_version)),
+ &console_format!("Version: <comment>{root_version}</comment>"),
);
console_writeln!(
console,
- &format!(
- "Licenses: {}",
- mozart_core::console::comment(&license_display)
- ),
+ &console_format!("Licenses: <comment>{license_display}</comment>"),
);
console_writeln!(console, "Dependencies:");
console_writeln!(console, "");
diff --git a/crates/mozart/src/commands/outdated.rs b/crates/mozart/src/commands/outdated.rs
index 2b25816..46f09f9 100644
--- a/crates/mozart/src/commands/outdated.rs
+++ b/crates/mozart/src/commands/outdated.rs
@@ -1,5 +1,6 @@
use clap::Args;
use indexmap::IndexSet;
+use mozart_core::console_format;
use mozart_core::console_writeln;
use mozart_core::matches_wildcard;
use std::cmp::Ordering;
@@ -442,7 +443,7 @@ fn render_text(entries: &[OutdatedEntry], console: &mozart_core::console::Consol
if entries.is_empty() {
console_writeln!(
console,
- &mozart_core::console::info("All packages are up to date.").to_string(),
+ &console_format!("<info>All packages are up to date.</info>"),
);
return;
}
@@ -467,16 +468,16 @@ fn render_text(entries: &[OutdatedEntry], console: &mozart_core::console::Consol
let (name_str, lat_str) = match entry.category {
UpdateCategory::UpToDate => (
- mozart_core::console::info(&name_col).to_string(),
- mozart_core::console::info(&lat_col).to_string(),
+ console_format!("<info>{name_col}</info>"),
+ console_format!("<info>{lat_col}</info>"),
),
UpdateCategory::SemverCompatible => (
- mozart_core::console::highlight(&name_col).to_string(),
- mozart_core::console::highlight(&lat_col).to_string(),
+ console_format!("<highlight>{name_col}</highlight>"),
+ console_format!("<highlight>{lat_col}</highlight>"),
),
UpdateCategory::SemverIncompatible => (
- mozart_core::console::comment(&name_col).to_string(),
- mozart_core::console::comment(&lat_col).to_string(),
+ console_format!("<comment>{name_col}</comment>"),
+ console_format!("<comment>{lat_col}</comment>"),
),
};
@@ -485,7 +486,7 @@ fn render_text(entries: &[OutdatedEntry], console: &mozart_core::console::Consol
&format!(
"{} {} {} {}",
name_str,
- mozart_core::console::comment(&cur_col),
+ console_format!("<comment>{cur_col}</comment>"),
lat_str,
entry.description
),
diff --git a/crates/mozart/src/commands/update.rs b/crates/mozart/src/commands/update.rs
index 79fd7ba..2e93a0c 100644
--- a/crates/mozart/src/commands/update.rs
+++ b/crates/mozart/src/commands/update.rs
@@ -1,6 +1,5 @@
use clap::Args;
use indexmap::{IndexMap, IndexSet};
-use mozart_core::console;
use mozart_core::console_format;
use mozart_core::package::{self, Stability};
use mozart_registry::lockfile;
@@ -536,10 +535,10 @@ pub fn expand_wildcards(
}
}
if !matched {
- console.info(&console::warning(&format!(
- "Package '{}' listed for update is not in the lock file. Specifier will be ignored.",
+ console.info(&console_format!(
+ "<warning>Package '{}' listed for update is not in the lock file. Specifier will be ignored.</warning>",
spec
- )));
+ ));
}
}
@@ -814,8 +813,8 @@ pub fn interactive_select_packages(
let stdin = io::stdin();
if !stdin.is_terminal() {
- console.info(&console::warning(
- "Interactive mode requires a TTY. Running non-interactively with all packages.",
+ console.info(&console_format!(
+ "<warning>Interactive mode requires a TTY. Running non-interactively with all packages.</warning>"
));
return packages;
}
diff --git a/crates/mozart/src/commands/validate.rs b/crates/mozart/src/commands/validate.rs
index 972593f..44e3f5e 100644
--- a/crates/mozart/src/commands/validate.rs
+++ b/crates/mozart/src/commands/validate.rs
@@ -774,18 +774,18 @@ fn output_result(
console.info(&console_format!(
"<info>{name} is valid for simple usage with Composer but has</info>"
));
- console.info(&mozart_core::console::info(
- "strict errors that make it unable to be published as a package",
+ console.info(&console_format!(
+ "<info>strict errors that make it unable to be published as a package</info>"
));
- console.info(&mozart_core::console::warning(
- "See https://getcomposer.org/doc/04-schema.md for details on the schema",
+ console.info(&console_format!(
+ "<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>"
));
} else if result.has_warnings() {
console.info(&console_format!(
"<info>{name} is valid, but with a few warnings</info>"
));
- console.info(&mozart_core::console::warning(
- "See https://getcomposer.org/doc/04-schema.md for details on the schema",
+ console.info(&console_format!(
+ "<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>"
));
} else if !lock_errors.is_empty() {
let kind = if check_lock { "errors" } else { "warnings" };
@@ -836,16 +836,12 @@ fn output_result(
// Print errors
for msg in &all_errors {
- if msg.starts_with('#') {
- console.error(&mozart_core::console::error(msg));
- } else {
- console.error(msg);
- }
+ console.error(msg);
}
for msg in &all_warnings {
if msg.starts_with('#') {
- console.info(&mozart_core::console::warning(msg));
+ console.info(&console_format!("<warning>{msg}</warning>"));
} else {
console.info(msg);
}