1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
//! CLI parser definition for `cargo ai profile`.
use clap::{Arg, ArgAction, ArgGroup, Command};
/// Builds the `profile` command schema and nested subcommands.
pub fn command() -> Command {
Command::new("profile")
.about("Manage connection profiles")
.subcommand(Command::new("list").about("List all configured profiles"))
.subcommand(
Command::new("show")
.about("Show detailed information for a specific profile")
.arg(
Arg::new("name")
.help("Name of the profile to display")
.required(true)
.value_name("NAME"),
),
)
.subcommand(
Command::new("add")
.about("Add a new connection profile or overwrite an existing one")
.arg(
Arg::new("name")
.help("Name of the profile to add or update")
.required(true)
.value_name("NAME"),
)
.arg(
Arg::new("server")
.long("server")
.short('s')
.help("LLM server (e.g., openai or ollama)")
.required(true)
.value_name("SERVER"),
)
.arg(
Arg::new("model")
.long("model")
.short('m')
.help("LLM model identifier (e.g., gpt-4o, mistral)")
.required(true)
.value_name("MODEL"),
)
.arg(
Arg::new("auth")
.long("auth")
.help("Optional auth mode (default: none)")
.required(false)
.value_name("MODE")
.value_parser(["none", "api_key", "openai_account"]),
)
.arg(
Arg::new("url")
.long("url")
.help("Custom transformer server URL (HTTPS preferred)")
.required(false)
.value_name("URL"),
)
.arg(
Arg::new("description")
.long("description")
.short('d')
.help("Optional description for the profile")
.required(false)
.value_name("TEXT"),
)
.arg(
Arg::new("default")
.long("default")
.help("Set this profile as the default")
.action(ArgAction::SetTrue),
),
)
.subcommand(
Command::new("set")
.about("Update fields for an existing profile")
.group(
ArgGroup::new("mutations")
.args([
"server",
"model",
"auth",
"url",
"clear_url",
"description",
"clear_description",
"token",
"stdin",
"env",
"clear_token",
"default",
])
.required(true),
)
.group(
ArgGroup::new("url_update")
.args(["url", "clear_url"])
.multiple(false),
)
.group(
ArgGroup::new("description_update")
.args(["description", "clear_description"])
.multiple(false),
)
.group(
ArgGroup::new("token_source")
.args(["token", "stdin", "env", "clear_token"])
.multiple(false),
)
.arg(
Arg::new("name")
.help("Name of the profile to update")
.required(true)
.value_name("NAME"),
)
.arg(
Arg::new("server")
.long("server")
.short('s')
.help("Update server (e.g., openai or ollama)")
.required(false)
.value_name("SERVER"),
)
.arg(
Arg::new("model")
.long("model")
.short('m')
.help("Update model identifier (e.g., gpt-5.2, mistral)")
.required(false)
.value_name("MODEL"),
)
.arg(
Arg::new("auth")
.long("auth")
.help("Update auth mode")
.required(false)
.value_name("MODE")
.value_parser(["none", "api_key", "openai_account"]),
)
.arg(
Arg::new("url")
.long("url")
.help("Set custom transformer server URL")
.required(false)
.value_name("URL"),
)
.arg(
Arg::new("clear_url")
.long("clear-url")
.help("Remove custom transformer server URL")
.required(false)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("description")
.long("description")
.short('d')
.help("Set profile description")
.required(false)
.value_name("TEXT"),
)
.arg(
Arg::new("clear_description")
.long("clear-description")
.help("Remove profile description")
.required(false)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("token")
.long("token")
.help("Set API token from literal value")
.required(false)
.value_name("TOKEN")
.num_args(1),
)
.arg(
Arg::new("stdin")
.long("stdin")
.help("Set API token from standard input")
.required(false)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("env")
.long("env")
.help("Set API token from environment variable")
.required(false)
.value_name("ENV_VAR")
.num_args(1),
)
.arg(
Arg::new("clear_token")
.long("clear-token")
.help("Clear stored API token for this profile")
.required(false)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("default")
.long("default")
.help("Set this profile as the default")
.required(false)
.action(ArgAction::SetTrue),
),
)
.subcommand(
Command::new("remove")
.about("Remove an existing connection profile by name")
.arg(
Arg::new("name")
.help("Name of the profile to remove")
.required(true)
.value_name("NAME"),
),
)
}