[−][src]Struct creator_tools::utils::Shell
An abstraction around console output that remembers preferences for output verbosity and color.
Implementations
impl Shell[src]
pub fn new() -> Shell[src]
Creates a new shell (color choice and verbosity), defaulting to 'auto' color and verbose output.
pub fn from_write(out: Box<dyn Write>) -> Shell[src]
Creates a shell from a plain writable object, with no color, and max verbosity.
pub fn set_needs_clear(&mut self, needs_clear: bool)[src]
Sets whether the next print should clear the current line.
pub fn is_cleared(&self) -> bool[src]
Returns true if the needs_clear flag is unset.
pub fn err_width(&self) -> TtyWidth[src]
Returns the width of the terminal in spaces, if any.
pub fn is_err_tty(&self) -> bool[src]
Returns true if stderr is a tty.
pub fn out(&mut self) -> &mut dyn Write[src]
Gets a reference to the underlying stdout writer.
pub fn err(&mut self) -> &mut dyn Write[src]
Gets a reference to the underlying stderr writer.
pub fn err_erase_line(&mut self)[src]
Erase from cursor to end of line.
pub fn status<T>(&mut self, status: T) -> Result<()> where
T: Display, [src]
T: Display,
Shortcut to right-align and color green a status.
pub fn status_message<T, U>(&mut self, status: T, message: U) -> Result<()> where
T: Display,
U: Display, [src]
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, [src]
T: Display,
pub fn status_with_color<T, U>(
&mut self,
status: T,
message: U,
color: Color
) -> Result<()> where
T: Display,
U: Display, [src]
&mut self,
status: T,
message: U,
color: Color
) -> Result<()> where
T: Display,
U: Display,
Shortcut to right-align a status message.
pub fn verbose<F>(&mut self, mut callback: F) -> Result<()> where
F: FnMut(&mut Shell) -> Result<()>, [src]
F: FnMut(&mut Shell) -> Result<()>,
Runs the callback only if we are in verbose mode.
pub fn concise<F>(&mut self, mut callback: F) -> Result<()> where
F: FnMut(&mut Shell) -> Result<()>, [src]
F: FnMut(&mut Shell) -> Result<()>,
Runs the callback if we are not in verbose mode.
pub fn error<T: Display>(&mut self, message: T) -> Result<()>[src]
Prints a red 'error' message.
pub fn warn<T: Display>(&mut self, message: T) -> Result<()>[src]
Prints an amber 'warning' message.
pub fn note<T: Display>(&mut self, message: T) -> Result<()>[src]
Prints a cyan 'note' message.
pub fn set_verbosity(&mut self, verbosity: Verbosity)[src]
Updates the verbosity of the shell.
pub fn verbosity(&self) -> Verbosity[src]
Gets the verbosity of the shell.
pub fn set_color_choice(&mut self, color: Option<&str>) -> Result<()>[src]
Updates the color choice (always, never, or auto) from a string..
pub fn color_choice(&self) -> ColorChoice[src]
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.
pub fn err_supports_color(&self) -> bool[src]
Whether the shell supports color.
pub fn print_ansi(&mut self, message: &[u8]) -> Result<()>[src]
Prints a message and translates ANSI escape code into console colors.
pub fn print_json<T: Serialize>(&mut self, obj: &T)[src]
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Shell[src]
impl !Send for Shell[src]
impl !Sync for Shell[src]
impl Unpin for Shell[src]
impl !UnwindSafe for Shell[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,