pub struct Printer { /* private fields */ }Expand description
Main printer for CLI output
Implementations§
Source§impl Printer
impl Printer
Sourcepub fn new(format: OutputFormat, verbose: bool) -> Self
pub fn new(format: OutputFormat, verbose: bool) -> Self
Creates a new printer with the specified format and verbosity.
Sourcepub fn from_flags(json: bool, verbose: bool) -> Self
pub fn from_flags(json: bool, verbose: bool) -> Self
Create a printer from common CLI flags.
Sourcepub fn success(&self, message: &str)
pub fn success(&self, message: &str)
Print a success message (human only — use print_empty_result for JSON-safe success)
Sourcepub fn print_empty_result(&self, action: &str, message: &str)
pub fn print_empty_result(&self, action: &str, message: &str)
Print a “nothing found” success result with JSON support.
In human mode, prints a green success message. In JSON mode, outputs structured JSON so scripts/LLMs always get parseable output.
Sourcepub fn print_processes_as(
&self,
action: &str,
processes: &[Process],
context: Option<&str>,
)
pub fn print_processes_as( &self, action: &str, processes: &[Process], context: Option<&str>, )
Print a list of processes with action name and optional context.
The action parameter sets the JSON action field (e.g. “list”, “by”, “stuck”).
Sourcepub fn print_processes_with_context(
&self,
processes: &[Process],
context: Option<&str>,
)
pub fn print_processes_with_context( &self, processes: &[Process], context: Option<&str>, )
Print a list of processes with optional context (e.g., “in /path/to/dir”). Uses “list” as the JSON action name.
Sourcepub fn print_processes(&self, processes: &[Process])
pub fn print_processes(&self, processes: &[Process])
Print a list of processes. Uses “list” as the JSON action name.
Sourcepub fn print_ports(&self, ports: &[PortInfo])
pub fn print_ports(&self, ports: &[PortInfo])
Print port information
Sourcepub fn print_port_info(&self, port_info: &PortInfo)
pub fn print_port_info(&self, port_info: &PortInfo)
Print a single port info (for proc on :port)
Sourcepub fn print_json<T: Serialize>(&self, data: &T)
pub fn print_json<T: Serialize>(&self, data: &T)
Print JSON output for any serializable type
Sourcepub fn print_action_result(
&self,
action: &str,
succeeded: &[Process],
failed: &[(Process, String)],
)
pub fn print_action_result( &self, action: &str, succeeded: &[Process], failed: &[(Process, String)], )
Print action result (generalized for kill/stop/unstick).
The action parameter should be a lowercase verb (e.g. “kill”, “stop”, “freeze”).
It is used as-is in JSON output and capitalized for human display.
Sourcepub fn print_kill_result(
&self,
killed: &[Process],
failed: &[(Process, String)],
)
pub fn print_kill_result( &self, killed: &[Process], failed: &[(Process, String)], )
Print kill result (delegates to print_action_result)
Sourcepub fn print_dry_run(&self, verb: &str, processes: &[Process])
pub fn print_dry_run(&self, verb: &str, processes: &[Process])
Print dry-run summary and return early.
Used by destructive commands (kill, stop, freeze, thaw) for consistent dry-run output.
Sourcepub fn ask_confirm(
&self,
action: &str,
processes: &[Process],
yes: bool,
) -> Result<bool>
pub fn ask_confirm( &self, action: &str, processes: &[Process], yes: bool, ) -> Result<bool>
Show confirmation prompt and return whether the user confirmed.
Returns Ok(true) if confirmed or skipped (–yes / –json).
Returns Ok(false) if the user declined (prints “Cancelled”).
Sourcepub fn print_confirmation(&self, action: &str, processes: &[Process])
pub fn print_confirmation(&self, action: &str, processes: &[Process])
Print a confirmation prompt showing processes about to be acted on