use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(
name = "cleanux",
version,
about = "Linux cleaner CLI (CleanMyMac-like)"
)]
pub struct Cli {
#[arg(long, global = true, default_value_t = false)]
pub apply: bool,
#[arg(long, global = true, default_value_t = false)]
pub yes: bool,
#[arg(long, global = true, default_value_t = ReportFormat::Text, value_enum)]
pub report: ReportFormat,
#[command(subcommand)]
pub cmd: Command,
}
#[derive(Subcommand, Debug)]
pub enum Command {
Scan {
#[arg(value_enum, default_value_t = Target::All)]
target: Target,
},
Clean {
#[arg(value_enum, default_value_t = Target::All)]
target: Target,
},
Dups {
#[arg(default_value = ".")]
path: PathBuf,
#[arg(long, default_value_t = false)]
trash: bool,
#[arg(long)]
min_bytes: Option<u64>,
#[arg(long)]
max_bytes: Option<u64>,
},
Large {
#[arg(default_value = ".")]
path: PathBuf,
#[arg(long, default_value_t = 25)]
top: usize,
#[arg(long)]
min_bytes: Option<u64>,
#[arg(long)]
max_bytes: Option<u64>,
},
}
#[derive(clap::ValueEnum, Clone, Copy, Debug)]
pub enum Target {
All,
Cache,
}
impl Target {
pub fn allows(self, group: crate::model::CleanerGroup) -> bool {
match self {
Target::All => true,
Target::Cache => group == crate::model::CleanerGroup::Cache,
}
}
}
#[derive(clap::ValueEnum, Clone, Debug)]
pub enum ReportFormat {
Text,
Json,
}