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).
Sourcepub fn raw(&mut self, bytes: &[u8])
pub fn raw(&mut self, bytes: &[u8])
bytes written as they are, nothing escaped: for text cuno wrote
itself, and for the output of a program the user asked cuno to run
(cuno test, cuno run), which can reach the terminal directly
anyway. A tool’s output goes through Shell::tool_output
(docs/en/specs/commands.md, “Format”).
Sourcepub fn tool_output(&mut self, bytes: &[u8], asked: bool)
pub fn tool_output(&mut self, bytes: &[u8], asked: bool)
The output of a tool cuno ran (a compiler, a linker, clang-tidy),
written as it was produced, not decoded, so text in the console’s
code page reaches the console as such, but with the control
characters it holds shown escaped. Its color sequences pass only when
asked, cuno having asked that tool for color; any other tool’s
are a project’s text (docs/en/specs/commands.md, “Format”).