pub struct Printer { /* private fields */ }Implementations§
Source§impl Printer
impl Printer
pub fn new(verbosity: Verbosity) -> Self
pub fn with_theme( verbosity: Verbosity, theme_config: Option<&ThemeConfig>, ) -> Self
Sourcepub fn disable_colors()
pub fn disable_colors()
Disable color output globally. Wraps the console crate’s color toggle
so that no other module needs to depend on console directly.
pub fn with_format( verbosity: Verbosity, theme_config: Option<&ThemeConfig>, output_format: OutputFormat, ) -> Self
pub fn verbosity(&self) -> Verbosity
Sourcepub fn for_test() -> (Self, Arc<Mutex<String>>)
pub fn for_test() -> (Self, Arc<Mutex<String>>)
Create a Printer that captures all output to a shared buffer. Use in tests to verify output content regardless of verbosity.
Sourcepub fn for_test_with_format(
output_format: OutputFormat,
) -> (Self, Arc<Mutex<String>>)
pub fn for_test_with_format( output_format: OutputFormat, ) -> (Self, Arc<Mutex<String>>)
Create a Printer with a specific output format that captures to a buffer.
pub fn header(&self, text: &str)
pub fn subheader(&self, text: &str)
pub fn success(&self, text: &str)
pub fn warning(&self, text: &str)
pub fn error(&self, text: &str)
pub fn info(&self, text: &str)
pub fn key_value(&self, key: &str, value: &str)
pub fn diff(&self, old: &str, new: &str)
pub fn syntax_highlight(&self, code: &str, language: &str)
pub fn progress_bar(&self, total: u64, message: &str) -> ProgressBar
pub fn spinner(&self, message: &str) -> ProgressBar
pub fn multi_progress(&self) -> &MultiProgress
pub fn plan_phase(&self, name: &str, items: &[String])
pub fn table(&self, headers: &[&str], rows: &[Vec<String>])
pub fn prompt_confirm(&self, message: &str) -> Result<bool, InquireError>
pub fn prompt_select<'a>( &self, message: &str, options: &'a [String], ) -> Result<&'a String, InquireError>
pub fn prompt_text( &self, message: &str, default: &str, ) -> Result<String, InquireError>
pub fn newline(&self)
Sourcepub fn stdout_line(&self, text: &str)
pub fn stdout_line(&self, text: &str)
Write a line to stdout (for machine-readable data output, not UI).
Used by commands like config get whose output may be captured by scripts.
Sourcepub fn is_structured(&self) -> bool
pub fn is_structured(&self) -> bool
Whether structured output mode is active (not table or wide).
Sourcepub fn write_structured<T: Serialize>(&self, value: &T) -> bool
pub fn write_structured<T: Serialize>(&self, value: &T) -> bool
Write a serializable value as structured output to stdout.
Returns true if output was emitted (caller should skip human formatting).
Returns false if output format is Table/Wide (caller should do human formatting).
Sourcepub fn run_with_output(
&self,
cmd: &mut Command,
label: &str,
) -> Result<CommandOutput>
pub fn run_with_output( &self, cmd: &mut Command, label: &str, ) -> Result<CommandOutput>
Run a command with live output display.
TTY mode: shows a spinner with the last N lines of output in a bounded region. On success, collapses to a summary line. On failure, shows full stderr.
Non-TTY / quiet mode: streams output lines as they arrive. Captures stdout/stderr for the return value.