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
impl Shell
Sourcepub fn new(
out: Box<dyn Write>,
choice: Option<ColorChoice>,
env: &Env,
out_is_terminal: bool,
) -> Shell
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”.
Sourcepub fn configure(&mut self, configured: Option<ColorChoice>, verbose: bool)
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.
Sourcepub fn set_verbosity(&mut self, verbosity: Verbosity)
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”).
Sourcepub fn uses_color(&self) -> bool
pub fn uses_color(&self) -> bool
Whether this shell writes color escape codes.
Sourcepub fn help(&mut self, message: impl Display)
pub fn help(&mut self, message: impl Display)
help: <message>, how to fix what the previous line reported.
Sourcepub fn status(&mut self, verb: &str, message: impl Display)
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).