1use anyhow::Result;
7use clap::Parser;
8use robonix_cli::Config;
9
10mod cmd;
11mod pb;
12
13#[derive(Parser)]
14#[command(name = "rbnx")]
15#[command(version)]
16#[command(about = "Robonix helper CLI for package validation, build, and local orchestration", long_about = None)]
17struct Cli {
18 #[command(subcommand)]
19 command: cmd::Commands,
20}
21
22#[tokio::main]
23async fn main() -> Result<()> {
24 env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
25 .filter_module("rustdds", log::LevelFilter::Off)
26 .filter_module("ros2_client", log::LevelFilter::Warn)
27 .init();
28
29 let cli = Cli::parse();
30
31 let config = Config::load()?;
32 config.ensure_storage_dir()?;
33
34 let needs_source = matches!(
39 &cli.command,
40 cmd::Commands::Build { .. }
41 | cmd::Commands::Start { .. }
42 | cmd::Commands::Validate { .. }
43 | cmd::Commands::Install { .. }
44 | cmd::Commands::Codegen { .. }
45 );
46 if needs_source {
47 let _ = config.require_source_path();
48 }
49
50 if let Err(e) = robonix_cli::PackageDatabase::sync(&config.package_storage_path) {
51 log::warn!("Package database sync failed: {}", e);
52 }
53
54 cmd::execute(cli.command, config).await?;
55
56 Ok(())
57}