Struct crossbundle_tools::types::Shell
source · [−]pub struct Shell { /* private fields */ }
Expand description
An abstraction around console output that remembers preferences for output verbosity and color.
Implementations
sourceimpl 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>) -> Shell
pub fn from_write(out: Box<dyn Write>) -> 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.
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>(&mut self, status: T) -> Result<()> where
T: Display,
pub fn status<T>(&mut self, status: T) -> Result<()> where
T: Display,
Shortcut to right-align and color green a status.
sourcepub fn status_message<T, U>(&mut self, status: T, message: U) -> Result<()> where
T: Display,
U: Display,
pub fn status_message<T, U>(&mut self, status: T, message: U) -> Result<()> where
T: Display,
U: Display,
Shortcut to right-align and color green a status message.
pub fn status_header<T>(&mut self, status: T) -> Result<()> where
T: Display,
sourcepub fn status_with_color<T, U>(
&mut self,
status: T,
message: U,
color: Color
) -> Result<()> where
T: Display,
U: Display,
pub fn status_with_color<T, U>(
&mut self,
status: T,
message: U,
color: Color
) -> Result<()> where
T: Display,
U: Display,
Shortcut to right-align a status message.
sourcepub fn verbose<F>(&mut self, callback: F) -> Result<()> where
F: FnMut(&mut Shell) -> Result<()>,
pub fn verbose<F>(&mut self, callback: F) -> Result<()> where
F: FnMut(&mut Shell) -> Result<()>,
Runs the callback only if we are in verbose mode.
sourcepub fn concise<F>(&mut self, callback: F) -> Result<()> where
F: FnMut(&mut Shell) -> Result<()>,
pub fn concise<F>(&mut self, callback: F) -> Result<()> where
F: FnMut(&mut Shell) -> Result<()>,
Runs the callback if we are not in verbose mode.
sourcepub fn warn<T: Display>(&mut self, message: T) -> Result<()>
pub fn warn<T: Display>(&mut self, message: T) -> Result<()>
Prints an amber ‘warning’ 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>) -> Result<()>
pub fn set_color_choice(&mut self, color: Option<&str>) -> Result<()>
Updates the color choice (always, never, or auto) from a string..
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.
sourcepub fn print_ansi(&mut self, message: &[u8]) -> Result<()>
pub fn print_ansi(&mut self, message: &[u8]) -> Result<()>
Prints a message and translates ANSI escape code into console colors.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Shell
impl !Send for Shell
impl !Sync for Shell
impl Unpin for Shell
impl !UnwindSafe for Shell
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more