use crate::{output::output::OutputKind, print_template, print_text, utils};
pub async fn execute() {
let cache_dir = utils::path::cache_dir();
let actions_dir = utils::path::actions_dir();
if let Err(e) = vibe_fs::clean(&actions_dir, Some(&cache_dir)) {
print_template!(
OutputKind::Error,
"Failed to clean actions cache: {error}",
"error" => e.to_string()
);
} else {
print_text!(OutputKind::Info, "Actions cache cleaned");
}
match std::fs::read_dir(std::env::temp_dir()) {
Ok(entries) => {
let mut count = 0;
for entry in entries.flatten() {
let name = entry.file_name();
let name_str = name.to_string_lossy();
if name_str.starts_with("vibe-") {
if std::fs::remove_file(entry.path()).is_ok() {
count += 1;
}
}
}
if count > 0 {
print_template!(
OutputKind::Info,
"Temp files cleaned: {count}",
"count" => count
);
}
}
Err(_) => {}
}
}