From 2bc47940be9359e34cfe50c64fe76234999bc716 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 6 May 2026 04:02:24 +0900 Subject: 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 --- crates/mozart-core/src/console.rs | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'crates/mozart-core/src') diff --git a/crates/mozart-core/src/console.rs b/crates/mozart-core/src/console.rs index 734074e..b8db17e 100644 --- a/crates/mozart-core/src/console.rs +++ b/crates/mozart-core/src/console.rs @@ -3,36 +3,42 @@ use dialoguer::{Confirm, Input}; use std::io::IsTerminal; // --------------------------------------------------------------------------- -// Tag-style color helpers (module-level free functions, unchanged API) +// Tag-style color helpers — called only by `console_format!` // --------------------------------------------------------------------------- -/// `` — green foreground -pub fn info(message: &str) -> ColoredString { +/// `` — green foreground. +/// Do not call directly; use the `console_format!` macro instead. +pub fn __format_info_message(message: &str) -> ColoredString { message.green() } -/// `` — yellow foreground -pub fn comment(message: &str) -> ColoredString { +/// `` — yellow foreground. +/// Do not call directly; use the `console_format!` macro instead. +pub fn __format_comment_message(message: &str) -> ColoredString { message.yellow() } -/// `` — white on red -pub fn error(message: &str) -> ColoredString { +/// `` — white on red. +/// Do not call directly; use the `console_format!` macro instead. +pub fn __format_error_message(message: &str) -> ColoredString { message.white().on_red() } -/// `` — black on cyan -pub fn question(message: &str) -> ColoredString { +/// `` — black on cyan. +/// Do not call directly; use the `console_format!` macro instead. +pub fn __format_question_message(message: &str) -> ColoredString { message.black().on_cyan() } -/// `` — red foreground (Composer extension) -pub fn highlight(message: &str) -> ColoredString { +/// `` — red foreground (Composer extension). +/// Do not call directly; use the `console_format!` macro instead. +pub fn __format_highlight_message(message: &str) -> ColoredString { message.red() } -/// `` — black on yellow (Composer extension) -pub fn warning(message: &str) -> ColoredString { +/// `` — black on yellow (Composer extension). +/// Do not call directly; use the `console_format!` macro instead. +pub fn __format_warning_message(message: &str) -> ColoredString { message.black().on_yellow() } @@ -148,7 +154,7 @@ impl Console { /// Write an error to stderr. Always shown, even in quiet mode. pub fn write_error(&self, msg: &str) { - eprintln!("{}", error(msg)); + eprintln!("{}", __format_error_message(msg)); } // Convenience verbosity-level shortcuts: -- cgit v1.3.1