Skip to main content

Printer

Struct Printer 

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

Implementations§

Source§

impl Printer

Source

pub fn new(verbosity: Verbosity) -> Self

Production constructor: stderr/stdout via console::Term.

Source

pub fn with_theme_name(verbosity: Verbosity, theme_name: Option<&str>) -> Self

Source

pub fn with_format( verbosity: Verbosity, theme_name: Option<&str>, output_format: OutputFormat, ) -> Self

Source

pub fn verbosity(&self) -> Verbosity

Source

pub fn output_format(&self) -> &OutputFormat

Source

pub fn is_structured(&self) -> bool

Source

pub fn is_wide(&self) -> bool

Source

pub fn disable_colors()

Disable color globally (today’s disable_colors).

Source

pub fn enable_colors()

Force color globally regardless of TTY detection. Symmetric to disable_colors so demo / example binaries that pipe their output for capture can still emit real ANSI escapes. Production CLI dispatch goes through with_format, which honors NO_COLOR and structured-output gating — call this only from non-production entry points.

Source

pub fn heading(&self, text: impl Into<String>)

Source

pub fn kv(&self, key: impl Into<String>, value: impl Into<String>)

Source

pub fn kv_block<I, K, V>(&self, pairs: I)
where I: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>,

Source

pub fn hint(&self, text: impl Into<String>)

Source

pub fn note(&self, text: impl Into<String>)

Source

pub fn table(&self, table: Table)

Source

pub fn status_simple(&self, role: Role, subject: impl Into<String>)

Status with no extra fields. For detail/duration/target, use the builder returned by the binding helper status (see status_builder.rs).

Source

pub fn status( &self, role: Role, subject: impl Into<String>, ) -> StatusBuilder<'_>

Status builder at depth 0. Commits on Drop.

Source

pub fn spinner(&self, message: impl Into<String>) -> Spinner<'_>

Top-level spinner (depth 0). Required for ~14 lib-side call sites in cfgd-core that today take &Printer and have no section context (oci/, upgrade/, sources/, modules/git.rs, reconciler/scripts.rs).

Source

pub fn progress_bar( &self, total: u64, message: impl Into<String>, ) -> ProgressBar<'_>

Source

pub fn multi_progress(&self) -> &MultiProgress

Expose the underlying MultiProgress for callers that need fine-grained control (kept for API parity with the old Printer).

Source

pub fn run( &self, cmd: &mut Command, label: impl Into<String>, ) -> Result<CommandOutput>

Run an external command at top-level (depth 0) with live output. TTY+non-quiet → spinner with tailing ring; otherwise → streaming lines. Either path captures full stdout/stderr in the returned CommandOutput.

Source

pub fn flush(&self)

Final flush — call at the end of a streaming command to ensure any buffered kvs land. (Drop on Printer would also do this but tests need explicit control.)

Source

pub fn render(&self, doc: Doc)

Force human render of a Doc to stderr, regardless of output_format. Used by tests; production code should call emit (T24) which routes by OutputFormat and falls back to this for human formats.

Source

pub fn emit(&self, doc: Doc)

Routed emit: structured formats go to stdout as JSON/YAML/etc.; Table/Wide go to stderr as the human render. This is the canonical buffered-output entry; production callers use this, not render.

Source

pub fn section(&self, name: impl Into<String>) -> SectionGuard<'_>

Source

pub fn section_or_collapse(&self, name: impl Into<String>) -> SectionGuard<'_>

Source§

impl Printer

Source

pub fn prompt_confirm(&self, message: &str) -> Result<bool, InquireError>

Source

pub fn prompt_select<'a>( &self, message: &str, options: &'a [String], ) -> Result<&'a String, InquireError>

Source

pub fn prompt_text( &self, message: &str, default: &str, ) -> Result<String, InquireError>

Source§

impl Printer

Source

pub fn diff(&self, old: &str, new: &str)

Diff renderer. Goes to stderr.

Source

pub fn syntax_highlight(&self, code: &str, lang: &str)

Syntax-highlighted code. Goes to stderr.

Source

pub fn data_line(&self, text: &str)

Raw stdout line, no decoration, no indent. For config get-shaped callers whose output is consumed by other programs.

Trait Implementations§

Source§

impl Drop for Printer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more