use crate::app_config::SupervisorConfig;
use crate::cli::commands::{handle_command, Commands};
use anyhow::Result;
use clap::Parser;
pub mod commands;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[arg(long, global = true)]
pub app: Option<String>,
#[command(subcommand)]
pub command: Option<Commands>,
}
impl Cli {
pub fn run(self) -> Result<()> {
match self.command {
Some(cmd) => {
let config = SupervisorConfig::load();
let app_config = config
.resolve_app(self.app.as_deref())
.map_err(|e| anyhow::anyhow!("{}", e))?;
handle_command(cmd, app_config)
}
None => {
println!("No command provided. Use --help for usage information.");
Ok(())
}
}
}
}