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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(
name = "zilliz",
about = "CLI and TUI for Zilliz Cloud",
version,
disable_help_flag = true,
disable_help_subcommand = true
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
/// Print help
#[arg(long, short, global = true, action = clap::ArgAction::SetTrue)]
pub help: bool,
/// Output format: json, table, text, yaml, csv
#[arg(long, short, global = true, default_value = "table")]
pub output: Option<String>,
/// JMESPath query to filter output
#[arg(long, global = true)]
pub query: Option<String>,
/// Suppress table/CSV header row
#[arg(long, global = true)]
pub no_header: bool,
}
#[derive(Subcommand)]
pub enum Commands {
/// Configure API key and default settings
#[command(hide = true, disable_help_subcommand = true)]
Configure {
#[command(subcommand)]
subcmd: Option<ConfigureCommands>,
},
/// Manage current cluster context
#[command(hide = true, disable_help_subcommand = true)]
Context {
#[command(subcommand)]
subcmd: Option<ContextCommands>,
},
/// Show CLI version
#[command(hide = true)]
Version,
/// Log in to Zilliz Cloud
#[command(hide = true)]
Login {
/// Don't automatically open the browser
#[arg(long)]
no_browser: bool,
/// Log in with API key (interactive prompt if no value given, or pass key directly)
#[arg(long, num_args(0..=1), default_missing_value = "")]
api_key: Option<String>,
/// Log in to the CN cloud (API key only)
#[arg(long, conflicts_with = "dev")]
cn: bool,
/// Log in to the internal UAT environment (API key only). Hidden from
/// public help output; intended for zilliz-tui contributors only. See
/// CONTRIBUTING.md.
#[arg(long, conflicts_with = "cn", hide = true)]
dev: bool,
},
/// Log out from Zilliz Cloud and clear stored credentials
#[command(hide = true)]
Logout,
/// Show current authentication status
#[command(alias = "info")]
Whoami,
/// Switch to a different organization
Switch {
/// Organization ID (interactive selection if omitted)
org_id: Option<String>,
},
/// Authentication commands (deprecated alias for `whoami` / `switch`)
#[command(hide = true, disable_help_subcommand = true)]
Auth {
#[command(subcommand)]
subcmd: Option<AuthCommands>,
},
/// Shell completion management
#[command(hide = true, disable_help_subcommand = true)]
Completion {
#[command(subcommand)]
subcmd: Option<CompletionCommands>,
},
/// View and manage command history
#[command(hide = true, disable_help_subcommand = true)]
History {
#[command(subcommand)]
subcmd: Option<HistoryCommands>,
},
/// Upgrade the CLI to the latest released version
#[command(alias = "update")]
Upgrade {
/// Only check for a newer version; do not run the installer
#[arg(long, short = 'c')]
check: bool,
/// Skip the confirmation prompt
#[arg(long, short = 'y')]
yes: bool,
/// Re-run the installer even when already on the latest version
#[arg(long, short = 'f')]
force: bool,
},
/// Guided onboarding for first-time users
Quickstart {
/// Skip prompts and print the cheatsheet only
#[arg(long)]
non_interactive: bool,
/// Skip the auth bootstrap step
#[arg(long)]
skip_login: bool,
},
/// Run a resource operation: zilliz <resource> <operation> [--flag value ...]
#[command(external_subcommand)]
External(Vec<String>),
}
#[derive(Subcommand)]
pub enum ContextCommands {
/// Set the current cluster context
Set {
/// Cluster ID
#[arg(long)]
cluster_id: Option<String>,
/// Cluster endpoint URL (auto-resolved from cluster-id if omitted)
#[arg(long)]
endpoint: Option<String>,
/// Database name
#[arg(long)]
database: Option<String>,
/// Resolve cluster details via the on-demand cluster API
/// (for VectorLake on-demand clusters)
#[arg(long)]
on_demand: bool,
},
/// Show the current context
Current {
/// Output format: json, table, text
#[arg(long, short)]
output: Option<String>,
},
/// Clear the current context
Clear,
}
#[derive(Subcommand)]
pub enum ConfigureCommands {
/// Set a configuration value
Set {
/// Configuration key (e.g. api_key, base_url)
key: String,
/// Value to set (omit for credential keys to enter securely via prompt)
value: Option<String>,
},
/// Get a configuration value
Get {
/// Configuration key
key: String,
},
/// List all configuration values
List,
/// Clear all stored credentials
Clear,
}
#[derive(Subcommand)]
pub enum AuthCommands {
/// Show current authentication status
Status,
/// Switch to a different organization
Switch {
/// Organization ID (interactive selection if omitted)
org_id: Option<String>,
},
}
#[derive(Subcommand)]
pub enum CompletionCommands {
/// Install shell completion to RC file
Install {
/// Shell type (auto-detected if omitted)
#[arg(value_enum)]
shell: Option<clap_complete::Shell>,
/// Automatically write to shell RC file
#[arg(long)]
apply: bool,
},
/// Remove shell completion from RC file
Uninstall {
/// Shell type (auto-detected if omitted)
#[arg(value_enum)]
shell: Option<clap_complete::Shell>,
},
/// Check if shell completion is installed
Status {
/// Shell type (auto-detected if omitted)
#[arg(value_enum)]
shell: Option<clap_complete::Shell>,
},
/// Print completion script to stdout
Show {
/// Shell type
#[arg(value_enum)]
shell: clap_complete::Shell,
},
}
#[derive(Subcommand)]
pub enum HistoryCommands {
/// List recent command history (default: last 50)
List {
/// Number of entries to show
#[arg(long, default_value = "50")]
limit: usize,
/// Show all entries
#[arg(long)]
all: bool,
},
/// Search command history by keyword
Search {
/// Search term (case-insensitive match on command field)
#[arg(long)]
keyword: String,
},
/// Clear all command history
Clear {
/// Skip confirmation prompt
#[arg(long)]
force: bool,
},
}