claude_code_switcher/
cli.rs1use clap::{Args, Parser, Subcommand};
2use std::path::PathBuf;
3
4use crate::snapshots::SnapshotScope;
5
6#[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#[derive(Subcommand)]
24pub enum Commands {
25 #[command(alias = "l", alias = "ls")]
27 List {
28 #[arg(long, short, help = "Show detailed information about each snapshot")]
30 verbose: bool,
31 },
32
33 #[command(alias = "s")]
35 Snap {
36 name: String,
38
39 #[arg(
41 long,
42 default_value = "common",
43 help = "Scope of settings to include in snapshot"
44 )]
45 scope: SnapshotScope,
46
47 #[arg(long, help = "Path to settings file (default: .claude/settings.json)")]
49 settings_path: Option<PathBuf>,
50
51 #[arg(long, help = "Description for the snapshot")]
53 description: Option<String>,
54
55 #[arg(long, help = "Overwrite existing snapshot with same name")]
57 overwrite: bool,
58 },
59
60 #[command(alias = "a")]
62 Apply {
63 target: String,
65
66 #[arg(long, default_value = "common", help = "Scope of settings to include")]
68 scope: SnapshotScope,
69
70 #[arg(long, help = "Override model setting")]
72 model: Option<String>,
73
74 #[arg(long, help = "Path to settings file (default: .claude/settings.json)")]
76 settings_path: Option<PathBuf>,
77
78 #[arg(long, help = "Create backup of current settings before applying")]
80 backup: bool,
81
82 #[arg(long, help = "Skip confirmation prompt")]
84 yes: bool,
85 },
86
87 #[command(alias = "rm", alias = "remove", alias = "del")]
89 Delete {
90 name: String,
92
93 #[arg(long, help = "Skip confirmation prompt")]
95 yes: bool,
96 },
97
98 #[command(subcommand)]
100 Credentials(CredentialCommands),
101}
102
103#[derive(Subcommand)]
105pub enum CredentialCommands {
106 #[command(alias = "ls")]
108 List,
109
110 #[command(alias = "rm")]
112 Delete {
113 id: String,
115 },
116
117 Clear {
119 #[arg(long, help = "Skip confirmation prompt")]
121 yes: bool,
122 },
123}
124
125#[derive(Args, Clone)]
127pub struct SnapArgs {
128 pub name: String,
130
131 #[arg(
133 long,
134 default_value = "common",
135 help = "Scope of settings to include in snapshot"
136 )]
137 pub scope: SnapshotScope,
138
139 #[arg(long, help = "Path to settings file (default: .claude/settings.json)")]
141 pub settings_path: Option<PathBuf>,
142
143 #[arg(long, help = "Description for the snapshot")]
145 pub description: Option<String>,
146
147 #[arg(long, help = "Overwrite existing snapshot with same name")]
149 pub overwrite: bool,
150}
151
152#[derive(Args, Clone)]
154pub struct ApplyArgs {
155 pub target: String,
157
158 #[arg(long, default_value = "common", help = "Scope of settings to include")]
160 pub scope: SnapshotScope,
161
162 #[arg(long, help = "Override model setting")]
164 pub model: Option<String>,
165
166 #[arg(long, help = "Path to settings file (default: .claude/settings.json)")]
168 pub settings_path: Option<PathBuf>,
169
170 #[arg(long, help = "Create backup of current settings before applying")]
172 pub backup: bool,
173
174 #[arg(long, help = "Skip confirmation prompt")]
176 pub yes: bool,
177}