use clap::Parser;
use std::io::IsTerminal;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
path: String,
#[arg(short, long, default_value = "*")]
matching: String,
#[arg(short, long)]
subfolders: usize,
#[arg(short, long, default_value = "group")]
prefix: String,
#[arg(long, default_value = "numbers")]
suffix: String,
#[arg(short, long)]
recursive: bool,
#[arg(long)]
dry_run: bool,
#[arg(short, long)]
force: bool,
#[arg(long)]
no_color: bool,
#[arg(short, long)]
verbose: bool,
#[arg(long, default_value = "name")]
sort: String,
#[arg(short, long)]
output_dir: Option<String>,
}
fn main() -> anyhow::Result<()> {
let args = Args::parse();
if args.subfolders == 0 {
anyhow::bail!("--subfolders must be greater than zero");
}
let color =
std::io::stdout().is_terminal() && !args.no_color && std::env::var("NO_COLOR").is_err();
refolder::run(&refolder::Config {
base_path: &args.path,
matching: &args.matching,
subfolders: args.subfolders,
prefix: &args.prefix,
suffix: &args.suffix,
recursive: args.recursive,
dry_run: args.dry_run,
force: args.force,
color,
verbose: args.verbose,
sort: &args.sort,
output_dir: args.output_dir.as_deref(),
})
}