mod config;
mod dag;
mod supervisor;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "arig", version, about = "Polyglot service orchestrator")]
struct Cli {
#[arg(short = 'C', long = "directory", value_name = "DIR")]
directory: Option<PathBuf>,
#[arg(short, long, default_value = "arig.yaml")]
file: PathBuf,
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Up,
Down,
Schema,
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
if let Some(dir) = &cli.directory {
std::env::set_current_dir(dir)
.map_err(|e| anyhow::anyhow!("failed to chdir to {}: {e}", dir.display()))?;
}
if let Commands::Schema = cli.command {
let schema = schemars::schema_for!(config::ArigConfig);
println!("{}", serde_json::to_string_pretty(&schema)?);
return Ok(());
}
let config = config::ArigConfig::load(&cli.file)?;
match cli.command {
Commands::Up => supervisor::up(config).await?,
Commands::Down => {
eprintln!("down: not yet implemented");
}
Commands::Schema => unreachable!(),
}
Ok(())
}