use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(
name = "codex-sync",
version,
about = "在局域网内同步 Codex 聊天记录和配置"
)]
pub(crate) struct Cli {
#[arg(long, global = true)]
pub(crate) config: Option<PathBuf>,
#[command(subcommand)]
pub(crate) command: Command,
}
#[derive(Subcommand)]
pub(crate) enum Command {
Init {
#[arg(long)]
force: bool,
},
Serve,
Peers {
#[arg(long, default_value_t = 3)]
seconds: u64,
},
Pull {
peer: String,
#[arg(long)]
overwrite: bool,
},
Status,
Usb {
#[command(subcommand)]
command: UsbCommand,
},
Smb {
#[command(subcommand)]
command: SmbCommand,
},
Relay {
#[command(subcommand)]
command: RelayCommand,
},
CcSwitch {
#[command(subcommand)]
command: CcSwitchCommand,
#[arg(long)]
codex_home: Option<PathBuf>,
#[arg(long)]
cc_switch_home: Option<PathBuf>,
},
History {
#[command(subcommand)]
command: HistoryCommand,
#[arg(long)]
codex_home: Option<PathBuf>,
},
Ssh {
#[command(subcommand)]
command: SshCommand,
},
}
#[derive(Subcommand)]
pub(crate) enum UsbCommand {
Export {
destination: PathBuf,
},
Import {
source: PathBuf,
#[arg(long)]
overwrite: bool,
},
List {
source: PathBuf,
},
}
#[derive(Subcommand)]
pub(crate) enum SmbCommand {
Push {
share: PathBuf,
},
Pull {
share: PathBuf,
#[arg(long)]
overwrite: bool,
},
List {
share: PathBuf,
},
}
#[derive(Subcommand)]
pub(crate) enum RelayCommand {
Push {
directory: PathBuf,
},
Pull {
directory: PathBuf,
#[arg(long)]
overwrite: bool,
},
List {
directory: PathBuf,
},
}
#[derive(Subcommand)]
pub(crate) enum CcSwitchCommand {
Status,
Merge {
#[arg(long)]
apply: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum HistoryCommand {
Status,
Doctor {
#[arg(long)]
apply: bool,
#[arg(long = "restore-missing", value_name = "BACKUP_JSONL")]
restore_missing: Vec<PathBuf>,
#[arg(long = "dedupe-session-meta", value_name = "ROLLOUT_JSONL")]
dedupe_session_meta: Option<PathBuf>,
},
#[command(alias = "sync")]
Merge {
#[arg(long)]
apply: bool,
},
Backup,
Restore {
backup: PathBuf,
#[arg(long)]
apply: bool,
},
}
#[derive(Subcommand)]
pub(crate) enum SshCommand {
Push {
host: String,
#[arg(long)]
codex_home: Option<PathBuf>,
#[arg(long)]
mirror: bool,
},
#[command(hide = true)]
Receive {
#[arg(long)]
bundle: PathBuf,
#[arg(long)]
codex_home: Option<PathBuf>,
#[arg(long)]
mirror: bool,
},
}