pub struct OutputManager {
    pub verbose: bool,
    /* private fields */
}
Expand description

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

Implementations

Returns an OutputManager of the specified verbosity.

Returns a new OutputManager with the same verbosity level, but with an indentation level incremented by one.

Returns a new OutputManager with the same verbosity level, but with an indentation level set to the level specified.

Displays a step. msg will be printed in yellow, prefixed by a +.

Displays a progress message. ̀msg` will be printed in white without a prefix.

Displays a success message. msg will be printed in green, prefixed by a ‘+’.

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.

Displays an error message. msg will be printed in red, prefixed by a ‘!’.

Displays a prompt. msg will be printed in blue, prefixed by a ‘?’. Will wait for user input before returning what the user typed.

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.

Displays a prompt for a password or any sensitive information. msg will be printed in blue, prefixed by a ‘?’. Will wait for user input before returning what the user typed.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.