claude_code_switcher/
cli.rs

1use clap::{Args, Parser, Subcommand};
2use std::path::PathBuf;
3
4use crate::snapshots::SnapshotScope;
5
6/// Main CLI parser
7#[derive(Parser)]
8#[command(about, version, author, long_about = None)]
9pub struct Cli {
10    #[command(subcommand)]
11    pub command: Commands,
12}
13
14/// Available CLI commands
15#[derive(Subcommand)]
16pub enum Commands {
17    /// List available snapshots [aliases: l, ls]
18    #[command(alias = "l", alias = "ls")]
19    List {
20        /// Show detailed information
21        #[arg(long, short, help = "Show detailed information about each snapshot")]
22        verbose: bool,
23    },
24
25    /// Create a snapshot of current settings [alias: s]
26    #[command(alias = "s")]
27    Snap {
28        /// Name for the snapshot
29        name: String,
30
31        /// What to include in the snapshot (default: common)
32        #[arg(
33            long,
34            default_value = "common",
35            help = "Scope of settings to include in snapshot"
36        )]
37        scope: SnapshotScope,
38
39        /// Path to settings file (default: .claude/settings.json)
40        #[arg(long, help = "Path to settings file (default: .claude/settings.json)")]
41        settings_path: Option<PathBuf>,
42
43        /// Description for the snapshot
44        #[arg(long, help = "Description for the snapshot")]
45        description: Option<String>,
46
47        /// Overwrite existing snapshot with same name
48        #[arg(long, help = "Overwrite existing snapshot with same name")]
49        overwrite: bool,
50    },
51
52    /// Apply a snapshot or template [alias: a]
53    #[command(alias = "a")]
54    Apply {
55        /// Snapshot name or template type (deepseek, glm, k2, k2-thinking, kat-coder-pro, kat-coder-air, kat-coder, kimi, longcat, minimax, seed-code)
56        target: String,
57
58        /// What to include in the snapshot (default: common)
59        #[arg(long, default_value = "common", help = "Scope of settings to include")]
60        scope: SnapshotScope,
61
62        /// Override model setting
63        #[arg(long, help = "Override model setting")]
64        model: Option<String>,
65
66        /// Path to settings file (default: .claude/settings.json)
67        #[arg(long, help = "Path to settings file (default: .claude/settings.json)")]
68        settings_path: Option<PathBuf>,
69
70        /// Backup current settings before applying
71        #[arg(long, help = "Create backup of current settings before applying")]
72        backup: bool,
73
74        /// Skip confirmation prompt
75        #[arg(long, help = "Skip confirmation prompt")]
76        yes: bool,
77    },
78
79    /// Delete a snapshot [aliases: rm, remove, del]
80    #[command(alias = "rm", alias = "remove", alias = "del")]
81    Delete {
82        /// Name of the snapshot to delete
83        name: String,
84
85        /// Skip confirmation prompt
86        #[arg(long, help = "Skip confirmation prompt")]
87        yes: bool,
88    },
89
90    /// Manage saved credentials
91    #[command(subcommand)]
92    Credentials(CredentialCommands),
93}
94
95/// Credential management commands
96#[derive(Subcommand)]
97pub enum CredentialCommands {
98    /// List saved credentials
99    #[command(alias = "ls")]
100    List,
101
102    /// Delete a saved credential
103    #[command(alias = "rm")]
104    Delete {
105        /// ID of the credential to delete
106        id: String,
107    },
108
109    /// Clear all saved credentials
110    Clear {
111        /// Skip confirmation prompt
112        #[arg(long, help = "Skip confirmation prompt")]
113        yes: bool,
114    },
115}
116
117/// Arguments for snapshot creation
118#[derive(Args, Clone)]
119pub struct SnapArgs {
120    /// Name for the snapshot
121    pub name: String,
122
123    /// What to include in the snapshot (default: common)
124    #[arg(
125        long,
126        default_value = "common",
127        help = "Scope of settings to include in snapshot"
128    )]
129    pub scope: SnapshotScope,
130
131    /// Path to settings file (default: .claude/settings.json)
132    #[arg(long, help = "Path to settings file (default: .claude/settings.json)")]
133    pub settings_path: Option<PathBuf>,
134
135    /// Description for the snapshot
136    #[arg(long, help = "Description for the snapshot")]
137    pub description: Option<String>,
138
139    /// Overwrite existing snapshot with same name
140    #[arg(long, help = "Overwrite existing snapshot with same name")]
141    pub overwrite: bool,
142}
143
144/// Arguments for applying snapshots/templates
145#[derive(Args, Clone)]
146pub struct ApplyArgs {
147    /// Snapshot name or template type
148    pub target: String,
149
150    /// What to include in the snapshot (default: common)
151    #[arg(long, default_value = "common", help = "Scope of settings to include")]
152    pub scope: SnapshotScope,
153
154    /// Override model setting
155    #[arg(long, help = "Override model setting")]
156    pub model: Option<String>,
157
158    /// Path to settings file (default: .claude/settings.json)
159    #[arg(long, help = "Path to settings file (default: .claude/settings.json)")]
160    pub settings_path: Option<PathBuf>,
161
162    /// Backup current settings before applying
163    #[arg(long, help = "Create backup of current settings before applying")]
164    pub backup: bool,
165
166    /// Skip confirmation prompt
167    #[arg(long, help = "Skip confirmation prompt")]
168    pub yes: bool,
169}