-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Console struct and implement
--quiet
command line option
Also, cleanup src/lib.rs - lexical order FTW
- Loading branch information
1 parent
a9c9d4b
commit 6af0001
Showing
8 changed files
with
134 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum Verbosity { | ||
Quiet, | ||
Normal, | ||
} | ||
|
||
impl Default for Verbosity { | ||
fn default() -> Self { | ||
Verbosity::Normal | ||
} | ||
} | ||
|
||
#[derive(Debug, Default)] | ||
pub struct Console { | ||
verbosity: Verbosity, | ||
} | ||
|
||
impl Console { | ||
pub fn with_verbosity(verbosity: Verbosity) -> Self { | ||
Self { verbosity } | ||
} | ||
|
||
pub fn new() -> Self { | ||
Default::default() | ||
} | ||
|
||
pub fn print_message(&self, message: &str) { | ||
if matches!(self.verbosity, Verbosity::Quiet) { | ||
return; | ||
} | ||
print!("{message}"); | ||
} | ||
|
||
pub fn print_error(&self, error: &str) { | ||
eprintln!("{error}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
mod app; | ||
mod console; | ||
mod directory_patcher; | ||
mod file_patcher; | ||
mod query; | ||
mod replacer; | ||
mod settings; | ||
pub use settings::Settings; | ||
mod stats; | ||
pub use crate::replacer::{replace, Replacement}; | ||
|
||
pub use app::run; | ||
pub use console::{Console, Verbosity}; | ||
pub use directory_patcher::DirectoryPatcher; | ||
pub use file_patcher::FilePatcher; | ||
pub use query::Query; | ||
pub use replacer::{replace, Replacement}; | ||
pub use settings::Settings; | ||
pub use stats::Stats; | ||
mod app; | ||
pub use app::run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.