[−][src]Struct rood::cli::output::OutputManager
The OutputManager is a nice wrapper over shell i/o functions.
It provides output nesting, various log levels and verbosity levels, as well as stack-like features for controlling more easily the indentation level of the output
Examples
Simple usage and stacked usage.
use rood::cli::OutputManager; let verbose_mode = false; let output = OutputManager::new(verbose_mode); output.step("[Step 1]"); output.push().debug("Some indented verbose-only message"); output.success("[Step 1] - OK")
Using a Yes/No prompt and handling errors.
use rood::cli::OutputManager; let output = OutputManager::new(false); match output.prompt_yn("Really to quit?", false) { Ok(val) => output.success(&format!("User picked: {}", val)), Err(e) => output.error(&format!("Error: {}", e)) }
Fields
verbose: bool
Methods
impl OutputManager
[src]
pub fn new(verbose: bool) -> OutputManager
[src]
Returns an OutputManager
of the specified verbosity.
pub fn push(&self) -> OutputManager
[src]
Returns a new OutputManager
with the same verbosity level, but with an indentation
level incremented by one.
pub fn with_padding(&self, padding: i32) -> OutputManager
[src]
Returns a new OutputManager
with the same verbosity level, but with an indentation
level set to the level specified.
pub fn step(&self, msg: &str)
[src]
Displays a step. msg
will be printed in yellow, prefixed by a +
.
pub fn progress(&self, msg: &str)
[src]
Displays a progress message. ̀msg` will be printed in white without a prefix.
pub fn success(&self, msg: &str)
[src]
Displays a success message. msg
will be printed in green, prefixed by a '+'.
pub fn debug(&self, msg: &str)
[src]
Displays a debug message. msg
will be printed in blue, prefixed by a '-'.
Note: Debug messages are only printed when the verbose flag is set.
pub fn error(&self, msg: &str)
[src]
Displays an error message. msg
will be printed in red, prefixed by a '!'.
pub fn prompt(&self, msg: &str) -> CausedResult<String>
[src]
Displays a prompt. msg
will be printed in blue, prefixed by a '?'.
Will wait for user input before returning what the user typed.
pub fn prompt_yn(&self, msg: &str, default: bool) -> CausedResult<bool>
[src]
Displays a yes/no prompt. msg
will be printed in blue, prefixed by a '?'.
Will wait for user input before returning what the user selected.
pub fn clear(&self) -> CausedResult<()>
[src]
Auto Trait Implementations
impl RefUnwindSafe for OutputManager
impl Send for OutputManager
impl Sync for OutputManager
impl Unpin for OutputManager
impl UnwindSafe for OutputManager
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,
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.
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>,