use clap::Parser;
use fast_clean::{run, Cli};
use crate::EXitCode::NoFound;

#[allow(dead_code, unused)]
enum EXitCode{
    Success,
    Failure,
    NoFound,
}
impl Into<i32> for EXitCode {
    fn into(self) -> i32 {
        match self {
            EXitCode::Success => 0,
            EXitCode::Failure => -1,
            EXitCode::NoFound => 1,
        }
    }
}

fn main(){
    let args = Cli::parse();
    let ret = run(&args);
    match ret {
        Ok(arr) => {
            if args.is_test {
                if arr.is_empty() {
                    println!("没有匹配的文件，退出");
                    std::process::exit(NoFound.into());
                } else {
                    println!("以下文件/文件夹将被删除：");
                    for file in &arr {
                        println!("{:?}", file);
                    }
                }
            } else {
                println!("删除完成");
            }
        }
        Err(e) => eprintln!("Error: {}", e),
    }
}
