From 945ec489c5481544d9b155254111b0e6e8c47a05 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Tue, 25 Jun 2024 05:38:16 +0200 Subject: [PATCH] Adds a way to clean either all or only .svg --- src/graphs.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/graphs.rs b/src/graphs.rs index d8b4c24..30822a6 100644 --- a/src/graphs.rs +++ b/src/graphs.rs @@ -32,6 +32,10 @@ pub(super) struct GraphConfig { /// Alternative config to load (generate a new one with init) #[arg(short, long)] config: Option, + + /// Clean all the artefacts (including generated images) + #[arg(short, long)] + all: bool, } #[derive(Debug, Clone)] @@ -82,18 +86,21 @@ fn load_graph_config(args: &GraphConfig) -> Result { } } /// Delete the existing graphs -fn del_graphs(_args: &GraphConfig) -> Result<()> { +fn del_graphs(args: &GraphConfig) -> Result<()> { let mut cmd = Command::new("rm"); cmd.args( glob("Images/Radar/*.svg")? .map(|v| v.unwrap().to_str().unwrap().to_string()) .collect::>(), ); - cmd.args( - glob("Images/Radar/*.png")? - .map(|v| v.unwrap().to_str().unwrap().to_string()) - .collect::>(), - ); + + if args.all { + cmd.args( + glob("Images/Radar/*.png")? + .map(|v| v.unwrap().to_str().unwrap().to_string()) + .collect::>(), + ); + } if let Err(e) = cmd.output() { println!( @@ -231,7 +238,7 @@ static STR_TO_GRAPH_TARGET_TYPE: phf::Map<&'static str, GraphTargetType> = phf_m "generate" => GraphTargetType::Generate, "gen" => GraphTargetType::Generate, "remove" => GraphTargetType::Remove, - "del" => GraphTargetType::Remove, + "clean" => GraphTargetType::Remove, "init" => GraphTargetType::Init, };