Skip to main content

Printer

Struct Printer 

Source
pub struct Printer { /* private fields */ }
Expand description

Main printer for CLI output

Implementations§

Source§

impl Printer

Source

pub fn new(format: OutputFormat, verbose: bool) -> Self

Creates a new printer with the specified format and verbosity.

Source

pub fn from_flags(json: bool, verbose: bool) -> Self

Create a printer from common CLI flags.

Source

pub fn success(&self, message: &str)

Print a success message (human only — use print_empty_result for JSON-safe success)

Source

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.

Source

pub fn error(&self, message: &str)

Print an error message

Source

pub fn warning(&self, message: &str)

Print a warning message

Source

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”).

Source

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.

Source

pub fn print_processes(&self, processes: &[Process])

Print a list of processes. Uses “list” as the JSON action name.

Source

pub fn print_ports(&self, ports: &[PortInfo])

Print port information

Source

pub fn print_port_info(&self, port_info: &PortInfo)

Print a single port info (for proc on :port)

Source

pub fn print_json<T: Serialize>(&self, data: &T)

Print JSON output for any serializable type

Source

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.

Source

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”).

Source

pub fn print_kill_result( &self, killed: &[Process], failed: &[(Process, String)], ) -> Result<()>

Print kill result (delegates to print_action_result)

Source

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.

Source

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"}.

Source

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”).

Source

pub fn print_confirmation(&self, action: &str, processes: &[Process])

Print a confirmation prompt showing processes about to be acted on

Trait Implementations§

Source§

impl Default for Printer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.