use anyhow::{Context, Result};
use clap::{Parser, Subcommand};
use std::path::PathBuf;
pub mod config;
pub mod hooks_writer;
pub mod install;
pub mod refresh;
pub mod start;
pub mod status;
pub mod stop;
pub mod uninstall;
#[derive(Parser, Debug)]
#[command(
name = "carryoverd",
version,
about = "Zero-LLM-token context-handoff daemon"
)]
pub struct Cli {
#[arg(short = 'c', long, global = true, value_name = "PATH")]
pub config: Option<PathBuf>,
#[arg(short = 'v', long, global = true)]
pub verbose: bool,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Install,
Refresh,
Status,
Start,
Stop,
Uninstall {
#[arg(long)]
purge: bool,
},
}
pub async fn run() -> Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::Install => install::run().context("install failed"),
Commands::Refresh => refresh::run().context("refresh failed"),
Commands::Status => status::run().context("status failed"),
Commands::Start => start::run().await.context("start failed"),
Commands::Stop => stop::run().context("stop failed"),
Commands::Uninstall { purge } => uninstall::run(purge).context("uninstall failed"),
}
}