pub struct Formatter { /* private fields */ }Expand description
Formatter for CLI output
Handles both human-readable and JSON output formats based on configuration. When JSON mode is enabled, all output is strict JSON without colors or progress.
Implementations§
Source§impl Formatter
impl Formatter
Sourcepub fn new(config: OutputConfig) -> Self
pub fn new(config: OutputConfig) -> Self
Create a new formatter with the given configuration
Sourcepub fn colors_enabled(&self) -> bool
pub fn colors_enabled(&self) -> bool
Check if colors are enabled
Sourcepub fn style_file(&self, text: &str) -> String
pub fn style_file(&self, text: &str) -> String
Style a file name (default)
Sourcepub fn style_size(&self, text: &str) -> String
pub fn style_size(&self, text: &str) -> String
Style a file size (green)
Sourcepub fn style_date(&self, text: &str) -> String
pub fn style_date(&self, text: &str) -> String
Style a timestamp/date (dim)
Sourcepub fn style_name(&self, text: &str) -> String
pub fn style_name(&self, text: &str) -> String
Style an alias/bucket name (bold)
Sourcepub fn style_tree_branch(&self, text: &str) -> String
pub fn style_tree_branch(&self, text: &str) -> String
Style tree branch characters (dim)
Sourcepub fn output<T: Serialize + Display>(&self, value: &T)
pub fn output<T: Serialize + Display>(&self, value: &T)
Output a value
In JSON mode, serializes the value to JSON. In human mode, uses the Display implementation.
Sourcepub fn error(&self, message: &str)
pub fn error(&self, message: &str)
Output an error message
Errors are always printed, even in quiet mode.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Formatter
impl RefUnwindSafe for Formatter
impl Send for Formatter
impl Sync for Formatter
impl Unpin for Formatter
impl UnsafeUnpin for Formatter
impl UnwindSafe for Formatter
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.