use std::path::PathBuf;
use clap::Parser;
use colored::Colorize;
use hermit::Context;
use hermit::Error;
use hermit::HermitData;
use reverie::ExitStatus;
use super::global_opts::GlobalOpts;
#[derive(Debug, Parser)]
pub struct CleanOpts {
#[clap(long, value_name = "DIR", env = "HERMIT_DATA_DIR")]
data_dir: Option<PathBuf>,
}
impl CleanOpts {
pub fn main(&self, global: &GlobalOpts) -> Result<ExitStatus, Error> {
let _guard = global.init_tracing();
let hermit = HermitData::from(self.data_dir.as_ref());
for id in hermit.try_recordings()? {
println!("{} {} ...", "Deleting".red().bold(), id.to_string().bold());
hermit
.remove(id)
.with_context(|| format!("Failed to delete recording {}", id))?;
}
Ok(ExitStatus::SUCCESS)
}
}