use anyhow::Result;
use clap::{Parser, Subcommand};
use tracing_subscriber::EnvFilter;
use atomr_infer_cli::{run_server, ProjectFile};
#[derive(Parser)]
#[command(name = "atomr-infer", version, about = "atomr-infer CLI")]
struct Cli {
#[command(subcommand)]
cmd: Cmd,
}
#[derive(Subcommand)]
enum Cmd {
Serve {
#[arg(short, long, value_name = "PATH")]
config: std::path::PathBuf,
},
Status {
#[arg(short, long, value_name = "PATH")]
config: std::path::PathBuf,
},
CostReport,
RotateCredentials { deployment: String },
}
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")))
.init();
let cli = Cli::parse();
match cli.cmd {
Cmd::Serve { config } => {
let project = ProjectFile::from_path(&config)?;
run_server(project).await
}
Cmd::Status { config } => {
let project = ProjectFile::from_path(&config)?;
for d in &project.deployments {
let runtime = d.effective_runtime();
println!(
"{:<32} model={:<48} runtime={:?} replicas={}",
d.name, d.model, runtime, d.replicas
);
}
Ok(())
}
Cmd::CostReport => {
println!("cost-report: not yet implemented (see doc §13 Phase 6)");
Ok(())
}
Cmd::RotateCredentials { deployment } => {
println!("rotate-credentials {deployment}: not yet implemented (see doc §13 Phase 6)");
Ok(())
}
}
}