Skip to content

Commit

Permalink
Add missing documentation
Browse files Browse the repository at this point in the history
dmerejkowsky committed May 13, 2022
1 parent db01d80 commit 32116f5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/console.rs
Original file line number Diff line number Diff line change
@@ -11,26 +11,34 @@ impl Default for Verbosity {
}

#[derive(Debug, Default)]
/// Used to print messages to the console according to a Verbosity
/// level
pub struct Console {
verbosity: Verbosity,
}

impl Console {
/// Create a new console with the given verbosity
pub fn with_verbosity(verbosity: Verbosity) -> Self {
Self { verbosity }
}

/// Create a new console with default verbosity
pub fn new() -> Self {
Default::default()
}

/// Print a message to the console
/// (using standard output)
pub fn print_message(&self, message: &str) {
if matches!(self.verbosity, Verbosity::Quiet) {
return;
}
print!("{message}");
}

/// Print an error message to the console
/// (using standard error)
pub fn print_error(&self, error: &str) {
eprintln!("{error}");
}

0 comments on commit 32116f5

Please sign in to comment.