use clap::Parser;
use log::LevelFilter;
use mles::ServerConfig;
use simple_logger::SimpleLogger;
use std::io;
use std::path::PathBuf;
const HISTORY_LIMIT: &str = "200";
const MAX_FILES_OPEN: &str = "256";
const TLS_PORT: &str = "443";
#[derive(Parser, Debug)]
struct Args {
#[arg(short, long, required = true)]
domains: Vec<String>,
#[arg(short, long)]
email: Vec<String>,
#[arg(short, long)]
cache: Option<PathBuf>,
#[arg(short, long, default_value = HISTORY_LIMIT, value_parser = clap::value_parser!(u32).range(1..1_000_000))]
limit: u32,
#[arg(short, long, default_value = MAX_FILES_OPEN, value_parser = clap::value_parser!(u32).range(1..1_000_000))]
filelimit: u32,
#[arg(short, long, required = true)]
wwwroot: PathBuf,
#[arg(short, long)]
staging: bool,
#[arg(short, long, default_value = TLS_PORT, value_parser = clap::value_parser!(u16).range(1..))]
port: u16,
#[arg(short, long)]
redirect: bool,
#[arg(short = 'C', long)]
compression_cache: Option<usize>,
}
#[tokio::main(flavor = "current_thread")]
async fn main() -> io::Result<()> {
SimpleLogger::new()
.with_level(LevelFilter::Warn)
.env()
.init()
.unwrap();
let args = Args::parse();
let config = ServerConfig {
domains: args.domains,
email: args.email,
cache: args.cache,
limit: args.limit,
filelimit: args.filelimit as usize,
wwwroot: args.wwwroot,
staging: args.staging,
port: args.port,
redirect: args.redirect,
max_cache_size_mb: args.compression_cache,
};
mles::run(config).await
}