use clap::Parser;
use log::info;
use pong_rs::settings::settings::{init_settings, SETTINGS};
use pong_rs::web_service_config::web_service_config;
use robotech::env::init_env;
use robotech::log::log::init_log;
use robotech::web_server::start_web_server;
#[derive(Parser, Debug)]
#[command(
author = env!("CARGO_PKG_AUTHORS"),
version,
about,
help_template = "{name} v{version} - {about}\n\nAUTHOR: {author}\n\nUSAGE: {usage}\n\nOPTIONS:\n{options}"
)]
struct Args {
#[arg(short, long)]
config_file: Option<String>,
#[arg(short, long)]
port: Option<u16>,
}
#[tokio::main]
async fn main() -> std::io::Result<()> {
info!("程序正在启动……");
info!("初始化环境变量...");
init_env();
info!("初始化日志系统...");
init_log()?;
info!("解析命令行参数...");
let args = Args::parse();
info!("初始化设置选项...");
init_settings(args.config_file, args.port);
let web_server_settings = SETTINGS.get().unwrap().web_server.clone();
start_web_server(web_server_settings, web_service_config).await;
info!("退出程序");
Ok(())
}