use psylink::prelude::*;
use clap::{Parser, Subcommand};
use std::error::Error;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Cli {
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
#[arg(short, long, value_name = "SECONDS", default_value_t = 3.0)]
scantime: f32,
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand, Debug)]
enum Commands {
Scan {},
Print {},
Train {},
Infer {},
#[cfg(feature = "gui")]
Gui {},
}
#[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<(), Box<dyn Error>> {
let cli = Cli::parse();
if cli.verbose > 1 {
dbg!(&cli);
}
let conf = App {
verbose: cli.verbose,
scantime: cli.scantime,
};
match &cli.command {
Some(Commands::Scan {}) => {
bluetooth::scan(conf).await?;
}
Some(Commands::Print {}) => {
bluetooth::stream(conf).await?;
}
Some(Commands::Train {}) => {
calibration::train()?;
}
Some(Commands::Infer {}) => {
calibration::infer()?;
}
#[cfg(feature = "gui")]
Some(Commands::Gui {}) | None => {
gui::start(conf).await;
}
#[cfg(not(feature = "gui"))]
None => {
<Cli as clap::CommandFactory>::command().print_help()?;
}
}
Ok(())
}