use anyhow::Result;
use clap::{Parser, Subcommand};
mod codegen;
mod commands;
mod mcp;
#[derive(Debug, Parser)]
#[command(
name = "cargo-taut",
bin_name = "cargo taut",
version,
about = "Codegen and IR tooling for taut-rpc.",
long_about = "Reads the taut-rpc IR (target/taut/ir.json) emitted by the \
proc-macros and either generates a typed TypeScript client, \
checks the IR against an expected version, or inspects it."
)]
struct Cli {
#[command(subcommand)]
cmd: Cmd,
}
#[derive(Debug, Subcommand)]
enum Cmd {
Gen(commands::gen::GenArgs),
Check(commands::check::CheckArgs),
Inspect(commands::inspect::InspectArgs),
Mcp(commands::mcp::McpArgs),
}
#[allow(clippy::similar_names)] fn main() -> Result<()> {
let mut argv: Vec<std::ffi::OsString> = std::env::args_os().collect();
if argv.get(1).is_some_and(|a| a == "taut") {
argv.remove(1);
}
let cli = Cli::parse_from(argv);
match cli.cmd {
Cmd::Gen(args) => commands::gen::run(args),
Cmd::Check(args) => commands::check::run(args),
Cmd::Inspect(args) => commands::inspect::run(args),
Cmd::Mcp(args) => commands::mcp::run(args),
}
}