Skip to main content

Shell

Struct Shell 

Source
pub struct Shell { /* private fields */ }
Expand description

Where cuno’s messages go (stderr for the binary). Crates write through a Shell instead of printing, so the color decision is made once.

Implementations§

Source§

impl Shell

Source

pub fn new( out: Box<dyn Write>, choice: Option<ColorChoice>, env: &Env, out_is_terminal: bool, ) -> Shell

A shell writing to out. choice is the color choice the user gave, or None when they gave none; out_is_terminal says whether out is a terminal.

With no choice given, NO_COLOR (set to anything, including empty) means no color, and otherwise color follows the terminal. A choice the user gave always wins over NO_COLOR, including an explicit auto. Shell::configure adds [term] color once it is read. See docs/en/specs/commands.md, “Available for all commands”.

Source

pub fn configure(&mut self, configured: Option<ColorChoice>, verbose: bool)

Applies [term], which is read after the shell is made: color ranks below --color and above NO_COLOR, and verbose makes the shell verbose unless -q or -v already decided.

Source

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

Applies -q or -v, once, before anything is written. Quiet, a Shell::status line writes nothing, and errors, warnings, help and other programs’ output are written as before (docs/en/specs/commands.md, “Available for all commands”).

Source

pub fn verbose(&self) -> bool

Whether to show what only -v shows, such as each step’s command.

Source

pub fn uses_color(&self) -> bool

Whether this shell writes color escape codes.

Source

pub fn error(&mut self, message: impl Display)

error: <message>.

Source

pub fn warning(&mut self, message: impl Display)

warning: <message>.

Source

pub fn help(&mut self, message: impl Display)

help: <message>, how to fix what the previous line reported.

Source

pub fn status(&mut self, verb: &str, message: impl Display)

A status line: verb right-aligned in 12 columns, then message, as in Compiling mygame v0.1.0. Nothing under -q (Shell::set_verbosity).

Source

pub fn raw(&mut self, bytes: &[u8])

Another program’s output (a compiler’s diagnostics), written as it was produced: not decoded, so text in the console’s code page reaches the console as such, and without anything added.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Shell

§

impl !Send for Shell

§

impl !Sync for Shell

§

impl !UnwindSafe for Shell

§

impl Forget for Shell

§

impl Freeze for Shell

§

impl Move for Shell

§

impl Unpin for Shell

§

impl UnsafeUnpin for Shell

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.