#![allow(dead_code, unused_imports)]
use clap::{CommandFactory, Parser, Subcommand};
use miette::Result;
mod commands;
mod compose;
mod config;
mod context;
mod error;
mod git;
mod mcp;
mod ports;
mod sanitize;
mod sync;
#[derive(Parser)]
#[command(
name = "rft",
version,
about = "Zero-config Docker Compose isolation for git worktrees"
)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
Start {
indices: Vec<usize>,
},
Stop {
indices: Vec<usize>,
},
Restart {
indices: Vec<usize>,
},
List,
Promote {
index: usize,
#[arg(long)]
dry_run: bool,
#[arg(long)]
files: Option<String>,
},
Clean,
Logs {
index: usize,
service: Option<String>,
#[arg(long)]
no_follow: bool,
},
Status,
Completions {
shell: clap_complete::Shell,
},
Mcp,
}
#[tokio::main]
async fn main() -> Result<()> {
miette::set_panic_hook();
let cli = Cli::parse();
match cli.command {
Command::List => commands::list::run().await,
Command::Start { indices } => commands::start::run(indices).await.map_err(Into::into),
Command::Stop { indices } => commands::stop::run(indices).await.map_err(Into::into),
Command::Restart { indices } => commands::restart::run(indices).await.map_err(Into::into),
Command::Promote {
index,
dry_run,
files,
} => commands::promote::run(index, dry_run, files.as_deref()).await,
Command::Clean => commands::clean::run().await.map_err(Into::into),
Command::Logs {
index,
service,
no_follow,
} => commands::logs::run(index, service, no_follow)
.await
.map_err(Into::into),
Command::Status => commands::status::run().await.map_err(Into::into),
Command::Completions { shell } => {
let mut cmd = Cli::command();
clap_complete::generate(shell, &mut cmd, "rft", &mut std::io::stdout());
Ok(())
}
Command::Mcp => mcp::server::run_mcp_server().await.map_err(Into::into),
}
}