Reporter

Struct Reporter 

Source
pub struct Reporter<'a> { /* private fields */ }
Expand description

Writes an Error to a destination.

Returned by Error::reporter.

Implementations§

Source§

impl<'a> Reporter<'a>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn report(self) -> Result<()>

Reports the error to the configured destination.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for Reporter<'a>

§

impl<'a> !RefUnwindSafe for Reporter<'a>

§

impl<'a> !Send for Reporter<'a>

§

impl<'a> !Sync for Reporter<'a>

§

impl<'a> Unpin for Reporter<'a>

§

impl<'a> !UnwindSafe for Reporter<'a>

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 = 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.