1use clap::Parser;
2use rustutils_runnable::Runnable;
3use std::error::Error;
4use std::fs::remove_file;
5use std::io;
6use std::path::PathBuf;
7
8#[derive(Parser, Clone, Debug)]
10#[clap(author, version, about)]
11pub struct Unlink {
12 #[clap(required = true)]
14 pub files: Vec<PathBuf>,
15}
16
17impl Unlink {
18 pub fn run(&self) -> Result<(), io::Error> {
20 for file in &self.files {
21 remove_file(&file)?;
22 }
23 Ok(())
24 }
25}
26
27impl Runnable for Unlink {
28 fn run(&self) -> Result<(), Box<dyn Error>> {
29 self.run().map_err(|e| Box::new(e) as Box<dyn Error>)
30 }
31}