#[derive(Debug, clap::Args)]
pub(crate) struct CleanCmd {
#[arg(short, long)]
dots: bool,
#[arg(short, long)]
backups: bool,
}
impl super::Command for CleanCmd {
fn run(
&self,
_: &super::nedots::RootCmd,
config: &crate::config::Config,
) -> Result<(), super::CommandError> {
if self.dots {
if dialoguer::Confirm::new()
.with_prompt("Cleaning dots. Continue?")
.interact()?
{
let dir = &config.dots_dir;
trash::delete(dir)?;
std::fs::create_dir_all(dir)?;
}
}
if self.backups {
if dialoguer::Confirm::new()
.with_prompt("Cleaning backups. Continue?")
.interact()?
{
let dir = &config.root.join("backups");
trash::delete(dir)?;
std::fs::create_dir_all(dir)?;
}
}
Ok(())
}
}