use crate::config::load_config;
use anyhow::Result;
use std::fs;
use std::path::PathBuf;
pub fn clean(clean_dirs: &[PathBuf]) -> Result<()> {
let default_dir = match load_config() {
Ok(config) => PathBuf::from(config.class_dir),
Err(_) => PathBuf::from("bin"),
};
let mut dirs = vec![default_dir];
dirs.extend_from_slice(clean_dirs);
for dir in dirs {
if dir.exists() {
fs::remove_dir_all(&dir)?;
info!("Cleaned {}", dir.display());
} else {
info!("Nothing to clean ({} does not exist)", dir.display());
}
}
Ok(())
}