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