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, };