[][src]Struct cargo::core::shell::Shell

pub struct Shell { /* fields omitted */ }

An abstraction around a Writeable object that remembers preferences for output verbosity and color.

Methods

impl Shell[src]

pub fn new() -> Shell[src]

Creates a new shell (color choice and verbosity), defaulting to 'auto' color and verbose output.

pub fn from_write(out: Box<dyn Write>) -> Shell[src]

Creates a shell from a plain writable object, with no color, and max verbosity.

pub fn set_needs_clear(&mut self, needs_clear: bool)[src]

Sets whether the next print should clear the current line.

pub fn is_cleared(&self) -> bool[src]

Returns true if the needs_clear flag is unset.

pub fn err_width(&self) -> Option<usize>[src]

Returns the width of the terminal in spaces, if any.

pub fn is_err_tty(&self) -> bool[src]

Returns true if stderr is a tty.

pub fn err(&mut self) -> &mut dyn Write[src]

Gets a reference to the underlying writer.

pub fn err_erase_line(&mut self)[src]

Erase from cursor to end of line.

pub fn status<T, U>(&mut self, status: T, message: U) -> CargoResult<()> where
    T: Display,
    U: Display
[src]

Shortcut to right-align and color green a status message.

pub fn status_header<T>(&mut self, status: T) -> CargoResult<()> where
    T: Display
[src]

pub fn status_with_color<T, U>(
    &mut self,
    status: T,
    message: U,
    color: Color
) -> CargoResult<()> where
    T: Display,
    U: Display
[src]

Shortcut to right-align a status message.

pub fn verbose<F>(&mut self, callback: F) -> CargoResult<()> where
    F: FnMut(&mut Shell) -> CargoResult<()>, 
[src]

Runs the callback only if we are in verbose mode.

pub fn concise<F>(&mut self, callback: F) -> CargoResult<()> where
    F: FnMut(&mut Shell) -> CargoResult<()>, 
[src]

Runs the callback if we are not in verbose mode.

pub fn error<T: Display>(&mut self, message: T) -> CargoResult<()>[src]

Prints a red 'error' message.

pub fn warn<T: Display>(&mut self, message: T) -> CargoResult<()>[src]

Prints an amber 'warning' message.

pub fn set_verbosity(&mut self, verbosity: Verbosity)[src]

Updates the verbosity of the shell.

pub fn verbosity(&self) -> Verbosity[src]

Gets the verbosity of the shell.

pub fn set_color_choice(&mut self, color: Option<&str>) -> CargoResult<()>[src]

Updates the color choice (always, never, or auto) from a string..

pub fn color_choice(&self) -> ColorChoice[src]

Gets the current color choice.

If we are not using a color stream, this will always return Never, even if the color choice has been set to something else.

pub fn supports_color(&self) -> bool[src]

Whether the shell supports color.

pub fn print_ansi(&mut self, message: &[u8]) -> CargoResult<()>[src]

Prints a message and translates ANSI escape code into console colors.

Trait Implementations

impl Default for Shell[src]

impl Debug for Shell[src]

Auto Trait Implementations

impl !Send for Shell

impl !Sync for Shell

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Same for T

type Output = T

Should always be Self