use std::path::PathBuf;
use clap::{Parser, Subcommand, ValueEnum};
pub const BANNER: &str = r#"
██╗ ██╗███╗ ██╗███████╗██╗ ██╗
██║ ██║████╗ ██║██╔════╝██║ ██╔╝
██║ ██║██╔██╗ ██║█████╗ █████╔╝
██║ ██║██║╚██╗██║██╔══╝ ██╔═██╗
╚██████╔╝██║ ╚████║██║ ██║ ██╗
╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═╝
"#;
#[derive(Parser, Debug)]
#[command(name = "unfk", version, about, long_about = None)]
#[command(before_help = BANNER)]
#[command(propagate_version = true, disable_version_flag = true)]
pub struct Cli {
#[arg(global = true)]
pub paths: Vec<PathBuf>,
#[command(subcommand)]
pub command: Option<Commands>,
#[arg(short, long, global = true)]
pub verbose: bool,
#[arg(short, long, global = true, conflicts_with = "verbose")]
pub quiet: bool,
#[arg(short, long, global = true, value_name = "FILE")]
pub config: Option<PathBuf>,
#[arg(long, global = true)]
pub no_gitignore: bool,
#[arg(long, global = true)]
pub no_editorconfig: bool,
#[arg(long, global = true)]
pub no_hidden: bool,
#[arg(long, global = true)]
pub include_binary: bool,
#[arg(long, global = true, value_name = "SIZE")]
pub max_size: Option<String>,
#[arg(long, global = true, value_name = "PATTERN")]
pub include: Vec<String>,
#[arg(long, global = true, value_name = "PATTERN")]
pub exclude: Vec<String>,
#[arg(long, global = true, value_name = "STYLE")]
pub line_ending: Option<LineEndingArg>,
#[arg(long, global = true, value_name = "STYLE")]
pub indent: Option<String>,
#[arg(long, global = true, value_name = "ENCODING")]
pub encoding: Option<String>,
#[arg(long, global = true)]
pub dry_run: bool,
#[arg(long, global = true)]
pub no_color: bool,
#[arg(short = 'V', long)]
pub version: bool,
}
impl Cli {
pub fn parse_args() -> Self {
Self::parse()
}
}
#[derive(Subcommand, Debug, Clone)]
pub enum Commands {
Scan {
#[arg()]
paths: Vec<PathBuf>,
},
Fix {
#[arg()]
paths: Vec<PathBuf>,
#[arg(long)]
dry_run: bool,
#[arg(long, short = 'a')]
all: bool,
},
Init {
#[arg(long)]
force: bool,
},
Types {
#[arg(long, value_name = "TYPE")]
show: Option<String>,
},
Config {
#[arg(long)]
dump: bool,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum LineEndingArg {
Lf,
Crlf,
Auto,
}