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)],
) -> Result<()>
pub fn print_action_result( &self, action: &str, succeeded: &[Process], failed: &[(Process, String)], ) -> Result<()>
Print action result (generalized for kill/stop/freeze/thaw).
The action parameter is the command name (e.g. “kill”, “stop”, “freeze”).
It is used as-is in JSON output and as the verb for human display.
Returns Err(ProcError::Reported) when any process failed, so the command
exits non-zero without printing a second result.
Sourcepub fn print_action_result_as(
&self,
action: &str,
verb: &str,
succeeded: &[Process],
failed: &[(Process, String)],
) -> Result<()>
pub fn print_action_result_as( &self, action: &str, verb: &str, succeeded: &[Process], failed: &[(Process, String)], ) -> Result<()>
Print action result where the JSON action differs from the verb shown
to humans (e.g. proc orphans --kill reports action “orphans”, verb “kill”).
Sourcepub fn print_kill_result(
&self,
killed: &[Process],
failed: &[(Process, String)],
) -> Result<()>
pub fn print_kill_result( &self, killed: &[Process], failed: &[(Process, String)], ) -> Result<()>
Print kill result (delegates to print_action_result)
Sourcepub fn print_dry_run(&self, action: &str, processes: &[Process])
pub fn print_dry_run(&self, action: &str, processes: &[Process])
Print dry-run summary for a destructive command.
The action is the command name (e.g. “kill”, “stop”, “freeze”, “thaw”),
used both as the JSON action and as the verb in the human summary.
Sourcepub fn print_dry_run_with(
&self,
action: &str,
processes: &[Process],
message: &str,
)
pub fn print_dry_run_with( &self, action: &str, processes: &[Process], message: &str, )
Print dry-run summary with a custom human message.
JSON output is always {"action", "success", "dry_run": true, "count", "processes"}.
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