pai_engine/
main.rs

1use anyhow::Result;
2use clap::{ArgAction, Parser};
3use std::path::PathBuf;
4use tracing::{error, info};
5use tracing_subscriber::FmtSubscriber;
6
7/// Command line arguments for the paiOS engine.
8#[derive(Parser, Debug)]
9#[command(author, version, about, long_about = None)]
10struct Args {
11    /// Path to the configuration file
12    #[arg(short, long)]
13    config: Option<PathBuf>,
14
15    /// Increase verbosity (-v, -vv, -vvv)
16    #[arg(short, long, action = ArgAction::Count)]
17    verbose: u8,
18}
19
20#[tokio::main]
21async fn main() -> Result<()> {
22    // 1. Parse command line arguments
23    let args = Args::parse();
24
25    // 2. Initialize logging (tracing) based on verbosity
26    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    // 3. Bootstrap engine (placeholder for now)
37    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    // TODO: In future steps, construct adapters and wire domain crates via `core`.
46
47    // 4. Wait for shutdown signal to keep the process alive
48    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}