rskiller 0.1.1

Find and clean Rust project build artifacts and caches
use clap::{Parser, ValueEnum};
use std::path::PathBuf;

#[derive(Parser, Clone, Debug)]
#[command(
    name = "rskill",
    about = "Find and clean Rust project build artifacts and caches",
    version = "0.1.0"
)]
pub struct Cli {
    /// Directory to start searching from
    #[arg(short, long, default_value = ".")]
    pub directory: PathBuf,

    /// Search from user's home directory
    #[arg(short = 'f', long)]
    pub full: bool,

    /// Target directories to search for (default: target)
    #[arg(short, long, default_value = "target")]
    pub target: String,

    /// Sort results by size, path, or last modified
    #[arg(short, long, value_enum, default_value = "size")]
    pub sort: SortBy,

    /// Show sizes in gigabytes instead of megabytes
    #[arg(long)]
    pub gb: bool,

    /// Exclude directories from search (comma-separated)
    #[arg(short = 'E', long)]
    pub exclude: Option<String>,

    /// Exclude hidden directories
    #[arg(short = 'x', long)]
    pub exclude_hidden: bool,

    /// Hide errors
    #[arg(short = 'e', long)]
    pub hide_errors: bool,

    /// Automatically delete all found directories
    #[arg(short = 'D', long)]
    pub delete_all: bool,

    /// Dry run - don't actually delete anything
    #[arg(long)]
    pub dry_run: bool,

    /// Just list projects without interactive mode
    #[arg(short, long)]
    pub list_only: bool,

    /// Show additional Rust-specific directories (registry cache, git cache, etc.)
    #[arg(long)]
    pub include_cargo_cache: bool,

    /// Color scheme for the interface
    #[arg(short = 'c', long, value_enum, default_value = "blue")]
    pub color: Color,

    /// Don't check for updates
    #[arg(long)]
    pub no_check_update: bool,
}

#[derive(ValueEnum, Clone, Debug)]
pub enum SortBy {
    Size,
    Path,
    LastMod,
}

#[derive(ValueEnum, Clone, Debug)]
pub enum Color {
    Blue,
    Cyan,
    Magenta,
    White,
    Red,
    Yellow,
}

impl Cli {
    pub fn get_search_directory(&self) -> PathBuf {
        if self.full {
            dirs::home_dir().unwrap_or_else(|| PathBuf::from("/"))
        } else {
            self.directory.clone()
        }
    }

    pub fn get_excluded_dirs(&self) -> Vec<String> {
        self.exclude
            .as_ref()
            .map(|s| {
                s.split(',')
                    .map(|dir| dir.trim().to_string())
                    .collect()
            })
            .unwrap_or_default()
    }
}