safe_remove/cli.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
use clap::{arg, Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(name = "srm", version = "1.0")]
#[command(author = "larpi")]
#[command(
about = "Securely remove files or directories",
long_about = "This command removes files or directories by overwriting them with random data."
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Safely remove files by moving them to a safe storage
Remove {
/// Retention duration for the removed files (e.g., "7d", "12h", "30m")
#[arg(short, long, value_name = "DURATION")]
duration: Option<String>,
/// Files to remove
#[arg(required = true, value_name = "FILE")]
files: Vec<String>,
},
/// Restore previously removed files to their original locations
Restore {
/// Restore all files
#[arg(short, long)]
all: bool,
/// Files to restore (specify file names as listed in storage)
#[arg(value_name = "FILE")]
files: Vec<String>,
},
/// List all files stored in the safe storage
List,
/// Clean the safe storage by removing expired files
Clean {
/// Force clean without confirmation
#[arg(short, long)]
force: bool,
},
/// View the contents of files
View {
/// File to view
#[arg(required = true, value_name = "FILE")]
files: Vec<String>,
},
}