safe_remove/
cli.rs

1use clap::{arg, Parser, Subcommand};
2#[derive(Parser, Debug)]
3#[command(name = "srm", version = "1.0")]
4#[command(author = "larpi")]
5#[command(
6    about = "Securely remove files or directories",
7    long_about = "This command removes files or directories by overwriting them with random data."
8)]
9pub struct Cli {
10    #[command(subcommand)]
11    pub command: Commands,
12}
13
14#[derive(Subcommand, Debug)]
15pub enum Commands {
16    /// Safely remove files by moving them to a safe storage
17    Remove {
18        /// Retention duration for the removed files (e.g., "7d", "12h", "30m")
19        #[arg(short, long, value_name = "DURATION")]
20        duration: Option<String>,
21
22        /// Files to remove
23        #[arg(required = true, value_name = "FILE")]
24        files: Vec<String>,
25    },
26
27    /// Restore previously removed files to their original locations
28    Restore {
29        /// Restore all files
30        #[arg(short, long)]
31        all: bool,
32
33        /// Files to restore (specify file names as listed in storage)
34        #[arg(value_name = "FILE")]
35        files: Vec<String>,
36    },
37
38    /// List all files stored in the safe storage
39    List,
40
41    /// Clean the safe storage by removing expired files
42    Clean {
43        /// Force clean without confirmation
44        #[arg(short, long)]
45        force: bool,
46    },
47
48    /// View the contents of files
49    View {
50        /// File to view
51        #[arg(required = true, value_name = "FILE")]
52        files: Vec<String>,
53    },
54
55    /// Configure the application
56    Config {
57        #[command(subcommand)]
58        action: ConfigAction,
59    },
60}
61
62#[derive(Subcommand, Debug)]
63pub enum ConfigAction {
64    /// Set a configuration key to a specific value
65    Set {
66        /// Configuration key to set (e.g., "default_duration")
67        #[arg(value_name = "KEY")]
68        key: String,
69
70        /// Value to assign to the key (e.g., "7d")
71        #[arg(value_name = "VALUE")]
72        value: String,
73    },
74
75    /// Get the value of a configuration key
76    Get {
77        /// Configuration key to retrieve
78        #[arg(value_name = "KEY")]
79        key: String,
80    },
81}