diff --git a/src/main.rs b/src/main.rs index 6c23393..abf79eb 100755 --- a/src/main.rs +++ b/src/main.rs @@ -160,12 +160,32 @@ fn main() { if let true = matches.is_present("reinit") { let config = workspace::read_cfg(); - Command::new("bash") - .args(&["-c", "rm -rf */"]) + let out = Command::new("bash") + .args(&["-c", "ls -A"]) + .output() + .unwrap() + .stdout; + let dirs_to_s = String::from_utf8_lossy(&*out); + let mut dirs = dirs_to_s.lines().collect::>(); + + let name = config.name.unwrap(); + + dirs.retain(|x| *x != "mlc.toml"); + dirs.retain(|x| *x != ".git"); + if config.mode == "repository" { + dirs.retain(|x| *x != "out"); + dirs.retain(|x| *x != name); + } + + info("Removing all repo directories to reinitialise".to_string()); + + Command::new("rm") + .args(&["-rf", &dirs.join(" ")]) .spawn() .unwrap() .wait() .unwrap(); + if config.mode == "workspace" { for r in config.repo { info(format!("Cloning (workspace mode): {}", r));