pub struct Shell { /* private fields */ }Expand description
An abstraction around console output that remembers preferences for output verbosity and color.
Implementations§
Source§impl Shell
impl Shell
Sourcepub fn new() -> Shell
pub fn new() -> Shell
Creates a new shell (color choice and verbosity), defaulting to ‘auto’ color and verbose output.
Sourcepub fn from_write(out: Box<dyn Write + Send + Sync>) -> Shell
pub fn from_write(out: Box<dyn Write + Send + Sync>) -> Shell
Creates a shell from a plain writable object, with no color, and max verbosity.
Sourcepub fn set_needs_clear(&mut self, needs_clear: bool)
pub fn set_needs_clear(&mut self, needs_clear: bool)
Sets whether the next print should clear the current line.
Sourcepub fn is_cleared(&self) -> bool
pub fn is_cleared(&self) -> bool
Returns true if the needs_clear flag is unset.
Sourcepub fn is_err_tty(&self) -> bool
pub fn is_err_tty(&self) -> bool
Returns true if stderr is a tty.
pub fn is_err_term_integration_available(&self) -> bool
Sourcepub fn err_erase_line(&mut self)
pub fn err_erase_line(&mut self)
Erase from cursor to end of line.
Sourcepub fn status<T, U>(&mut self, status: T, message: U) -> CargoResult<()>
pub fn status<T, U>(&mut self, status: T, message: U) -> CargoResult<()>
Shortcut to right-align and color green a status message.
pub fn transient_status<T>(&mut self, status: T) -> CargoResult<()>where
T: Display,
Sourcepub fn status_with_color<T, U>(
&mut self,
status: T,
message: U,
color: &Style,
) -> CargoResult<()>
pub fn status_with_color<T, U>( &mut self, status: T, message: U, color: &Style, ) -> CargoResult<()>
Shortcut to right-align a status message.
Sourcepub fn verbose<F>(&mut self, callback: F) -> CargoResult<()>
pub fn verbose<F>(&mut self, callback: F) -> CargoResult<()>
Runs the callback only if we are in verbose mode.
Sourcepub fn concise<F>(&mut self, callback: F) -> CargoResult<()>
pub fn concise<F>(&mut self, callback: F) -> CargoResult<()>
Runs the callback if we are not in verbose mode.
Sourcepub fn error<T: Display>(&mut self, message: T) -> CargoResult<()>
pub fn error<T: Display>(&mut self, message: T) -> CargoResult<()>
Prints a red ‘error’ message.
Sourcepub fn warn<T: Display>(&mut self, message: T) -> CargoResult<()>
pub fn warn<T: Display>(&mut self, message: T) -> CargoResult<()>
Prints an amber ‘warning’ message.
Sourcepub fn note<T: Display>(&mut self, message: T) -> CargoResult<()>
pub fn note<T: Display>(&mut self, message: T) -> CargoResult<()>
Prints a cyan ‘note’ message.
Sourcepub fn set_verbosity(&mut self, verbosity: Verbosity)
pub fn set_verbosity(&mut self, verbosity: Verbosity)
Updates the verbosity of the shell.
Sourcepub fn set_color_choice(&mut self, color: Option<&str>) -> CargoResult<()>
pub fn set_color_choice(&mut self, color: Option<&str>) -> CargoResult<()>
Updates the color choice (always, never, or auto) from a string..
pub fn set_unicode(&mut self, yes: bool) -> CargoResult<()>
pub fn set_hyperlinks(&mut self, yes: bool) -> CargoResult<()>
pub fn out_unicode(&self) -> bool
pub fn err_unicode(&self) -> bool
Sourcepub fn color_choice(&self) -> ColorChoice
pub fn color_choice(&self) -> ColorChoice
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.
Sourcepub fn err_supports_color(&self) -> bool
pub fn err_supports_color(&self) -> bool
Whether the shell supports color.
pub fn out_supports_color(&self) -> bool
pub fn out_hyperlink<D: Display>(&self, url: D) -> Hyperlink<D>
pub fn err_hyperlink<D: Display>(&self, url: D) -> Hyperlink<D>
pub fn out_file_hyperlink(&mut self, path: &Path) -> Hyperlink<String>
pub fn err_file_hyperlink(&mut self, path: &Path) -> Hyperlink<String>
pub fn set_unstable_flags_rustc_unicode(&mut self, yes: bool) -> CargoResult<()>
Sourcepub fn print_ansi_stderr(&mut self, message: &[u8]) -> CargoResult<()>
pub fn print_ansi_stderr(&mut self, message: &[u8]) -> CargoResult<()>
Prints a message to stderr and translates ANSI escape code into console colors.
Sourcepub fn print_ansi_stdout(&mut self, message: &[u8]) -> CargoResult<()>
pub fn print_ansi_stdout(&mut self, message: &[u8]) -> CargoResult<()>
Prints a message to stdout and translates ANSI escape code into console colors.
pub fn print_json<T: Serialize>(&mut self, obj: &T) -> CargoResult<()>
Sourcepub fn print_report(
&mut self,
report: Report<'_>,
force: bool,
) -> CargoResult<()>
pub fn print_report( &mut self, report: Report<'_>, force: bool, ) -> CargoResult<()>
Prints the passed in Report to stderr