use clap::{ArgAction, Parser, ValueEnum};
use clap_color_help::default_styles;
use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum ColorWhen {
Auto,
Always,
Never,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum SortBy {
Name,
Time,
Size,
Extension,
None,
}
#[derive(Debug, Parser)]
#[command(version, about, long_about = None, styles=default_styles())]
pub struct Cli {
pub paths: Vec<PathBuf>,
#[arg(short = 'a', long = "all")]
pub all: bool,
#[arg(short = 'A', long = "almost-all")]
pub almost_all: bool,
#[arg(short = 'l', long = "long")]
pub long: bool,
#[arg(short = '1', long = "oneline")]
pub oneline: bool,
#[arg(long = "tree", num_args = 0..=1, default_missing_value = "0")]
pub tree: Option<usize>,
#[arg(long = "gs", visible_alias = "git-status")]
pub git_status: bool,
#[arg(long = "sd", visible_aliases = ["sort-dirs", "group-directories-first"])]
pub group_directories_first: bool,
#[arg(long = "sf", visible_alias = "sort-files")]
pub sort_files_first: bool,
#[arg(short = 't')]
pub sort_time: bool,
#[arg(short = 'S', long = "sort-size")]
pub sort_size: bool,
#[arg(short = 'X', long = "sort-extension")]
pub sort_extension: bool,
#[arg(short = 'r', long = "reverse")]
pub reverse: bool,
#[arg(long = "light", conflicts_with = "dark")]
pub light: bool,
#[arg(long = "dark")]
pub dark: bool,
#[arg(long = "report")]
pub report: bool,
#[arg(long = "no-icons")]
pub no_icons: bool,
#[arg(long = "icons", conflicts_with = "no_icons")]
pub icons: bool,
#[arg(long = "color", value_enum, default_value_t = ColorWhen::Auto)]
pub color: ColorWhen,
#[arg(short = 'R', long = "recursive")]
pub recursive: bool,
#[arg(long = "config", value_name = "PATH")]
pub config_path: Option<PathBuf>,
#[arg(long = "init-config")]
pub init_config: bool,
#[arg(long = "print-config-dir")]
pub print_config_dir: bool,
#[arg(short = 'q', long = "quiet")]
pub quiet: bool,
#[arg(short = 'v', long = "verbose", action = ArgAction::Count)]
pub verbose: u8,
#[arg(short = 'p', long = "paginate")]
pub paginate: bool,
}
impl Cli {
pub fn show_hidden(&self) -> bool {
self.all || self.almost_all
}
pub fn include_dot_entries(&self) -> bool {
self.all && !self.almost_all
}
}