pub struct Reporter<'a> { /* private fields */ }Expand description
Writes an Error to a destination.
Returned by Error::reporter.
Implementations§
Source§impl<'a> Reporter<'a>
impl<'a> Reporter<'a>
Sourcepub fn color(self, color: Color) -> Self
pub fn color(self, color: Color) -> Self
Configures whether to use ANSI colors.
By default (if this function isn’t called), Reporter will respect any
a --color=<always|auto|never> argument that was encountered on the command line
(this mechanism requires the Command implementor to have an argument
of type Color).
If no --color argument was passed, and this method isn’t called, the default is
Color::Auto.
Sourcepub fn wrap_width(self, width: usize) -> Self
pub fn wrap_width(self, width: usize) -> Self
Sets the maximum line width.
Lines will be soft-wrapped if they exceed this width.
By default, lines will get wrapped after an unspecified, but typically reasonable width.
Sourcepub fn output<W: Write + IsTerminal + 'a>(self, w: W) -> Self
pub fn output<W: Write + IsTerminal + 'a>(self, w: W) -> Self
Writes output to the given destination.
The provided type has to implement IsTerminal for automatic colorization to work.
To output to something that does not implement IsTerminal, use Reporter::raw_output.
Sourcepub fn raw_output<W: Write + 'a>(self, w: W) -> Self
pub fn raw_output<W: Write + 'a>(self, w: W) -> Self
Writes the error to an io::Write implementor.
This will not use ANSI colors unless colors are forcibly enabled by passing --color=always
or calling Reporter::color with Color::Always.
Sourcepub fn report_and_exit(self) -> !
pub fn report_and_exit(self) -> !
Reports the error to the configured destination, and exits the process with an appropriate status.
If the Error is fatal (ie. the result of an incorrect command invocation), this will
exit with code EX_USAGE (64).
Otherwise, the Error indicates that the user requested --help or --version output,
and this method will exit the process with code 0.