1use anyhow::Result;
2use clap::{ArgAction, Parser};
3use std::path::PathBuf;
4use tracing::{error, info};
5use tracing_subscriber::FmtSubscriber;
6
7#[derive(Parser, Debug)]
9#[command(author, version, about, long_about = None)]
10struct Args {
11 #[arg(short, long)]
13 config: Option<PathBuf>,
14
15 #[arg(short, long, action = ArgAction::Count)]
17 verbose: u8,
18}
19
20#[tokio::main]
21async fn main() -> Result<()> {
22 let args = Args::parse();
24
25 let log_level = match args.verbose {
27 0 => tracing::Level::INFO,
28 1 => tracing::Level::DEBUG,
29 _ => tracing::Level::TRACE,
30 };
31
32 let subscriber = FmtSubscriber::builder().with_max_level(log_level).finish();
33
34 tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
35
36 info!("Booting paiOS engine workspace...");
38
39 if let Some(path) = args.config {
40 info!("Using configuration from: {}", path.display());
41 } else {
42 info!("No configuration file provided, using defaults.");
43 }
44
45 if let Err(e) = tokio::signal::ctrl_c().await {
49 error!("Failed to listen for shutdown signal: {e}");
50 }
51
52 info!("Shutdown signal received. Exiting paiOS engine.");
53
54 Ok(())
55}