use clap::Parser;
use std::path::PathBuf;
mod checks;
use checks::file::check_file;
use checks::port::check_port;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
#[arg(value_name = "INPUT")]
input: Option<String>,
#[arg(short, long, value_name = "PORT")]
port: Option<u16>,
#[arg(short, long, value_name = "FILE")]
file: Option<PathBuf>,
#[arg(short, long, default_value_t = false)]
verbose: bool,
}
fn main() {
let args = Args::parse();
if args.verbose {
println!("Verbose logging enabled.");
}
if let Some(port) = args.port {
check_port(port, args.verbose);
} else if let Some(file) = args.file {
check_file(file, args.verbose);
} else if let Some(input) = args.input {
if let Ok(port) = input.parse::<u16>() {
check_port(port, args.verbose);
} else {
check_file(PathBuf::from(input), args.verbose);
}
} else {
println!("Error: No input provided. Run with --help for usage details.");
}
}