use carryctx::application::runtime::InvocationContext;
use carryctx::error::ExitCode;
use clap::Parser;
#[derive(Parser, Debug)]
pub enum SyncCommand {
Push {
#[arg(long, default_value = "/tmp/carryctx-remote")]
remote: String,
},
Pull {
#[arg(long, default_value = "/tmp/carryctx-remote")]
remote: String,
},
}
#[derive(Parser, Debug)]
pub struct SyncArgs {
#[command(subcommand)]
pub command: SyncCommand,
}
pub fn handle_sync(
args: &SyncArgs,
ctx: &InvocationContext,
is_json: bool,
) -> Result<ExitCode, ExitCode> {
let work_dir = crate::resolve_work_dir(ctx);
match &args.command {
SyncCommand::Push { remote } => {
let result = carryctx::application::sync::sync_push(work_dir, remote);
crate::render_and_print("sync.push", result, is_json, ctx.quiet)
}
SyncCommand::Pull { remote } => {
let result = carryctx::application::sync::sync_pull(work_dir, remote);
crate::render_and_print("sync.pull", result, is_json, ctx.quiet)
}
}
}