pub struct OutputContext {
pub format: OutputFormat,
pub color_enabled: bool,
pub is_tty: bool,
pub term_width: u16,
pub verbose: bool,
pub quiet: bool,
}Expand description
Output context carrying terminal capabilities and user preferences.
§Invariants
formatmatches the user’s--formatflag.color_enabledaccounts for--color,NO_COLORenv, and terminal detection.is_ttyis true only when stdout is an interactive terminal.verboseandquietare never both true.
Fields§
§format: OutputFormatSelected output format.
color_enabled: boolWhether color output is enabled (resolved from flag + env + terminal).
is_tty: boolWhether stdout is an interactive terminal.
term_width: u16Terminal width in columns. Falls back to 80.
verbose: boolWhether verbose output is requested.
quiet: boolWhether quiet mode is requested (errors only).
Implementations§
Source§impl OutputContext
impl OutputContext
Sourcepub fn from_global_opts(opts: &GlobalOpts) -> Self
pub fn from_global_opts(opts: &GlobalOpts) -> Self
Construct an OutputContext from the global CLI options.
COLD PATH — called once per invocation.
Sourcepub fn render<T: Serialize + HumanRenderable>(&self, result: &T)
pub fn render<T: Serialize + HumanRenderable>(&self, result: &T)
Print a structured result in the selected format.
COLD PATH — called once per command result.
Sourcepub fn print_status(&self, symbol: &str, message: &str)
pub fn print_status(&self, symbol: &str, message: &str)
Print a progress message (suppressed in quiet mode and JSON mode).
Sourcepub fn print_warning(&self, message: &str)
pub fn print_warning(&self, message: &str)
Print a warning message.
Sourcepub fn print_fatal(&self, message: &str)
pub fn print_fatal(&self, message: &str)
Print a fatal error message (always shown, even in quiet mode).
Sourcepub fn print_debug(&self, message: &str)
pub fn print_debug(&self, message: &str)
Print a debug message (only in verbose mode).
Sourcepub fn progress_bar(&self, total: u64, message: &str) -> Option<ProgressBar>
pub fn progress_bar(&self, total: u64, message: &str) -> Option<ProgressBar>
Create an indicatif progress bar. Returns None if inappropriate.
Sourcepub fn spinner(&self, message: &str) -> Option<ProgressBar>
pub fn spinner(&self, message: &str) -> Option<ProgressBar>
Create a spinner for unbounded operations. Returns None if inappropriate.
Trait Implementations§
Source§impl Clone for OutputContext
impl Clone for OutputContext
Source§fn clone(&self) -> OutputContext
fn clone(&self) -> OutputContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for OutputContext
impl RefUnwindSafe for OutputContext
impl Send for OutputContext
impl Sync for OutputContext
impl Unpin for OutputContext
impl UnsafeUnpin for OutputContext
impl UnwindSafe for OutputContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more