diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cli.rs | 14 | ||||
| -rw-r--r-- | src/lib.rs | 2 | ||||
| -rw-r--r-- | src/main.rs | 2 |
3 files changed, 16 insertions, 2 deletions
@@ -15,7 +15,7 @@ impl Cli { matches } - pub async fn execute(matches: ArgMatches<'_>) { + pub async fn execute(matches: ArgMatches<'_>) -> Result<(), Box<dyn std::error::Error>> { if Config::get().whirlsplash.log.test { error!("error"); warn!("warn"); @@ -43,7 +43,17 @@ impl Cli { Self::cli().gen_completions(env!("CARGO_PKG_NAME"), Shell::Fish, "."); } debug!("generated shell completions"); + } else if matches.is_present("clean") { + let cleanable_directories = vec!["./log"]; + for dir in cleanable_directories { + println!("cleaning directory '{}'", dir); + if let Err(e) = std::fs::remove_dir_all(dir) { + bail!("error delete directory '{}': {}", dir, e); + } + } } + + Ok(()) } fn cli<'a, 'b>() -> App<'a, 'b> { @@ -67,6 +77,8 @@ impl Cli { SubCommand::with_name("zsh"), SubCommand::with_name("fish"), ]), + SubCommand::with_name("clean") + .about("Delete Whirl generated files/ directories which are NOT critical. E.g., logs/"), ]) .args(&[ Arg::with_name("debug").short("d").long("debug"), @@ -19,6 +19,8 @@ extern crate diesel; extern crate serde_derive; #[macro_use] extern crate async_trait; +#[macro_use] +extern crate simple_error; pub mod cli; pub mod config; diff --git a/src/main.rs b/src/main.rs index 97ecf4a..8182fff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box<dyn Error>> { .start()?; // Execution - Cli::execute(matches).await; + Cli::execute(matches).await.unwrap(); Ok(()) } |