1use super::types::FlagSchema;
6
7#[derive(Debug, Clone)]
13pub struct Flag {
14 pub short: Option<char>,
15 pub long: String,
16 pub description: String,
17 pub default: Option<String>,
18 pub arg: Option<String>,
19}
20
21impl Flag {
22 pub fn new(long: &str, desc: &str) -> Self {
23 Self {
24 short: None,
25 long: long.to_string(),
26 description: desc.to_string(),
27 default: None,
28 arg: None,
29 }
30 }
31
32 pub fn with_short(mut self, short: char) -> Self {
33 self.short = Some(short);
34 self
35 }
36
37 pub fn with_default(mut self, default: &str) -> Self {
38 self.default = Some(default.to_string());
39 self
40 }
41
42 pub fn with_arg(mut self, arg: &str) -> Self {
43 self.arg = Some(arg.to_string());
44 self
45 }
46}
47
48#[derive(Debug, Clone)]
50pub struct Route {
51 pub verb: &'static str,
52 pub summary: &'static str,
53 pub usage: &'static str,
54}
55
56pub struct CommandDef {
62 pub name: &'static str,
63 pub summary: &'static str,
64 pub usage: &'static str,
65 pub flags: Vec<FlagSchema>,
66}
67
68pub fn all_commands() -> Vec<CommandDef> {
70 vec![
71 CommandDef {
72 name: "server",
73 summary: "Start the database server (router/HTTP/gRPC/wire)",
74 usage: "red server [--grpc] [--http] [--grpc-bind 127.0.0.1:55055] [--http-bind 127.0.0.1:5000] [--wire-bind 127.0.0.1:5050] [--path ./data/reddb.rdb]",
75 flags: server_flags(),
76 },
77 CommandDef {
78 name: "service",
79 summary: "Install or inspect a systemd service",
80 usage: "red service <install|print-unit> [--binary /usr/local/bin/red] [--grpc-bind 0.0.0.0:55055] [--http-bind 0.0.0.0:5000] [--path /var/lib/reddb/data.rdb]",
81 flags: service_flags(),
82 },
83 CommandDef {
84 name: "query",
85 summary: "Execute a query against the database",
86 usage: "red query \"SELECT * FROM users WHERE age > $1\" -p 21",
87 flags: query_flags(),
88 },
89 CommandDef {
90 name: "insert",
91 summary: "Insert an entity into a collection",
92 usage: "red insert users '{\"name\": \"Alice\", \"age\": 30}'",
93 flags: insert_flags(),
94 },
95 CommandDef {
96 name: "get",
97 summary: "Get an entity by ID from a collection",
98 usage: "red get users abc123",
99 flags: get_flags(),
100 },
101 CommandDef {
102 name: "delete",
103 summary: "Delete an entity by ID from a collection",
104 usage: "red delete users abc123",
105 flags: delete_flags(),
106 },
107 CommandDef {
108 name: "health",
109 summary: "Run a health check against the server",
110 usage: "red health [--bind 127.0.0.1:5050] [--grpc|--http]",
111 flags: health_flags(),
112 },
113 CommandDef {
114 name: "tick",
115 summary: "Run maintenance/reclaim tick operations",
116 usage: "red tick [--bind 127.0.0.1:5000] [--operations maintenance,retention,checkpoint] [--dry-run]",
117 flags: tick_flags(),
118 },
119 CommandDef {
120 name: "migrate-from-redis",
121 summary: "Validate Redis to Blob Cache migration readiness; dual-write uses the documented application-owned helper pattern",
122 usage: "red migrate-from-redis --dry-run --redis-url redis://127.0.0.1:6379/0 [--path ./data/reddb.rdb]",
123 flags: migrate_from_redis_flags(),
124 },
125 CommandDef {
126 name: "migrate-pager-zone",
127 summary: "Convert a closed legacy sidecar-backed store to the zoned .rdb format",
128 usage: "red migrate-pager-zone --path ./data/reddb.rdb [--json]",
129 flags: migrate_pager_zone_flags(),
130 },
131 CommandDef {
132 name: "compact",
133 summary: "Rewrite a closed checkpointed native paged database into a fresh directory",
134 usage: "red compact --source data.rdb --destination-dir compacted [--json]",
135 flags: vec![
136 FlagSchema::new("source").with_description("Closed, checkpointed source .rdb; preserved unchanged"),
137 FlagSchema::new("destination-dir").with_description("New output directory; must not exist"),
138 FlagSchema::boolean("retain-canonical-system-config").with_description("Migrate a populated red_config tree into an empty red.config identity and retire the obsolete name"),
139 ],
140 },
141 CommandDef {
142 name: "recover-paged-wal",
143 summary: "Replay a supported pending WAL against an isolated copy",
144 usage: "red recover-paged-wal --source data.rdb --destination-dir recovered [--json]",
145 flags: vec![
146 FlagSchema::new("source").with_description("Closed source .rdb; preserved unchanged"),
147 FlagSchema::new("destination-dir").with_description("New output directory; must not exist"),
148 FlagSchema::boolean("retain-canonical-system-config").with_description("On the isolated copy, retain red.config and reject WAL actions for red_config"),
149 ],
150 },
151 CommandDef {
152 name: "scrub-paged-trees",
153 summary: "Check tree structure in a closed checkpointed paged database",
154 usage: "red scrub-paged-trees --source data.rdb [--json]",
155 flags: vec![FlagSchema::new("source").with_description("Closed, checkpointed source .rdb; preserved unchanged")],
156 },
157 CommandDef {
158 name: "scrub-paged",
159 summary: "Verify a supported closed checkpointed paged store",
160 usage: "red scrub-paged --source data.rdb [--json]",
161 flags: vec![FlagSchema::new("source").with_description("Closed, checkpointed source .rdb; preserved unchanged")],
162 },
163 CommandDef {
164 name: "salvage-paged-indexes",
165 summary: "Recover a paged store with corrupt secondary indexes into a fresh directory",
166 usage: "red salvage-paged-indexes --source data.rdb --destination-dir recovered [--json]",
167 flags: vec![
168 FlagSchema::new("source").with_description("Closed, checkpointed source .rdb; preserved unchanged"),
169 FlagSchema::new("destination-dir").with_description("New output directory; must not exist"),
170 ],
171 },
172 CommandDef {
173 name: "salvage-paged-collections",
174 summary: "Recover intact collections from a restricted legacy paged store",
175 usage: "red salvage-paged-collections --source data.rdb --destination-dir recovered [--json]",
176 flags: vec![
177 FlagSchema::new("source").with_description("Closed, checkpointed source .rdb; preserved unchanged"),
178 FlagSchema::new("destination-dir").with_description("New output directory; must not exist"),
179 ],
180 },
181 CommandDef {
182 name: "salvage",
183 summary: "Extract verified data from a damaged embedded store into a fresh .rdb",
184 usage: "red salvage --source damaged.rdb --destination recovered.rdb [--json]",
185 flags: salvage_flags(),
186 },
187 CommandDef {
188 name: "replica",
189 summary: "Start as a read replica connected to a primary",
190 usage: "red replica --primary-addr http://primary:55055 [--grpc] [--http] [--grpc-bind 127.0.0.1:55055] [--http-bind 127.0.0.1:5000] [--path ./data/reddb.rdb]",
191 flags: replica_flags(),
192 },
193 CommandDef {
194 name: "status",
195 summary: "Show replication status",
196 usage: "red status [--bind 0.0.0.0:6380]",
197 flags: status_flags(),
198 },
199 CommandDef {
200 name: "inspect",
201 summary: "Inspect on-disk database state (catalog snapshot)",
202 usage: "red inspect catalog --path <FILE> [--at <SEQ>] [--json]",
203 flags: inspect_flags(),
204 },
205 CommandDef {
206 name: "mcp",
207 summary: "Start MCP server for AI agent integration",
208 usage: "red mcp [--path /data | --url <URI>] [--token <token>]",
209 flags: mcp_flags(),
210 },
211 CommandDef {
212 name: "acp",
213 summary: "Start an embedded ACP agent backed by ASK",
214 usage: "red acp [--path /data/reddb.rdb]",
215 flags: acp_flags(),
216 },
217 CommandDef {
218 name: "auth",
219 summary: "Manage authentication (users, tokens, roles)",
220 usage: "red auth <subcommand>",
221 flags: auth_flags(),
222 },
223 CommandDef {
224 name: "connect",
225 summary: "Connect to a remote RedDB server (interactive REPL)",
226 usage: "red connect [--token <token>] [--query <sql>] <addr>",
227 flags: connect_flags(),
228 },
229 CommandDef {
230 name: "dump",
231 summary: "Export one or all collections as JSONL for backup/migration",
232 usage: "red dump [--path file] [--collection NAME] [-o FILE]",
233 flags: dump_flags(),
234 },
235 CommandDef {
236 name: "restore",
237 summary: "Import a previously dumped JSONL file into the database",
238 usage: "red restore [--path file] -i FILE [--collection NAME]",
239 flags: restore_flags(),
240 },
241 CommandDef {
242 name: "pitr-list",
243 summary: "List available point-in-time restore points from a snapshot archive",
244 usage: "red pitr-list --snapshot-prefix DIR --wal-prefix DIR",
245 flags: pitr_list_flags(),
246 },
247 CommandDef {
248 name: "pitr-restore",
249 summary: "Restore a database to a specific point in time from snapshots + WAL archive",
250 usage: "red pitr-restore --target-time UNIX_MS --dest PATH --snapshot-prefix DIR --wal-prefix DIR",
251 flags: pitr_restore_flags(),
252 },
253 CommandDef {
254 name: "doctor",
255 summary: "Health-check a running server against operator thresholds (PLAN.md Phase 5.5)",
256 usage: "red doctor [--bind 127.0.0.1:5000] [--token <admin>] [--json] [--backup-age-warn-secs 600] [--backup-age-crit-secs 3600] [--wal-lag-warn 1000] [--wal-lag-crit 10000]",
257 flags: doctor_flags(),
258 },
259 CommandDef {
260 name: "bootstrap",
261 summary: "One-shot first-admin bootstrap for headless containers / K8s Jobs",
262 usage: "red bootstrap --path PATH --vault [--username USER] [--password-stdin] [--print-certificate] [--json]",
263 flags: bootstrap_flags(),
264 },
265 CommandDef {
266 name: "version",
267 summary: "Show RedDB version information",
268 usage: "red version",
269 flags: vec![],
270 },
271 CommandDef {
272 name: "vcs",
273 summary: "Version-control operations (Git for Data)",
274 usage: "red vcs <commit|branch|branches|tag|tags|checkout|merge|log|status|lca|resolve> [args] [flags]",
275 flags: vcs_flags(),
276 },
277 CommandDef {
278 name: "ui",
279 summary: "Open a graphical UI against a local .rdb or a remote red:///reds:// instance over a RedWire-over-WS bridge",
280 usage: "red ui file://./data.rdb | red ui red://host:port [--token TOKEN] [--ui-dir DIR] [--port N] [--tls-ca PEM] [--no-browser]",
281 flags: ui_flags(),
282 },
283 ]
284}
285
286pub fn flags_for_command(command: Option<&str>) -> Vec<FlagSchema> {
291 let mut flags = super::types::global_flags();
292 if matches!(command, Some("dump")) {
293 flags.retain(|flag| flag.long != "output" && flag.short != Some('o'));
294 }
295
296 if command == Some("admin") {
297 flags.extend(admin_flags());
298 return flags;
299 }
300 if command == Some("rpc") {
301 flags.extend(rpc_flags());
302 return flags;
303 }
304 if let Some(definition) = all_commands()
305 .into_iter()
306 .find(|definition| Some(definition.name) == command)
307 {
308 flags.extend(definition.flags);
309 }
310 flags
311}
312
313pub fn main_help_text() -> String {
315 let mut out = String::with_capacity(1024);
316
317 out.push_str("reddb -- unified multi-model database engine\n");
318 out.push('\n');
319 out.push_str("Usage: red <command> [args] [flags]\n");
320 out.push('\n');
321
322 out.push_str("Commands:\n");
323 for cmd in all_commands() {
324 out.push_str(&format!(" {:<14} {}\n", cmd.name, cmd.summary));
325 }
326 out.push_str(&format!(" {:<14} {}\n", "help", "Show help for a command"));
327 out.push('\n');
328
329 out.push_str("Global flags:\n");
330 out.push_str(&format!(" {:<24} {}\n", "-h, --help", "Show help"));
331 out.push_str(&format!(" {:<24} {}\n", "-j, --json", "Force JSON output"));
332 out.push_str(&format!(
333 " {:<24} {}\n",
334 "-o, --output FORMAT", "Output format [text|json|yaml]"
335 ));
336 out.push_str(&format!(" {:<24} {}\n", "-v, --verbose", "Verbose output"));
337 out.push_str(&format!(
338 " {:<24} {}\n",
339 " --no-color", "Disable colors"
340 ));
341 out.push_str(&format!(" {:<24} {}\n", " --version", "Show version"));
342 out.push('\n');
343
344 out.push_str("Examples:\n");
345 out.push_str(" red server --path ./data/reddb.rdb\n");
346 out.push_str(" red server --grpc-bind 127.0.0.1:55055 --http-bind 127.0.0.1:5000 --path ./data/reddb.rdb\n");
347 out.push_str(" red server --wire-bind 127.0.0.1:5050 --path ./data/reddb.rdb\n");
348 out.push_str(" sudo red service install --binary /usr/local/bin/red --grpc-bind 0.0.0.0:55055 --http-bind 0.0.0.0:5000 --path /var/lib/reddb/data.rdb\n");
349 out.push_str(" red replica --primary-addr http://primary:55055 --path ./data/replica.rdb\n");
350 out.push_str(" red query \"SELECT * FROM users\"\n");
351 out.push_str(" red insert users '{\"name\": \"Alice\"}'\n");
352 out.push_str(" red get users abc123\n");
353 out.push_str(" red health\n");
354 out.push_str(
355 " red tick --bind 127.0.0.1:5000 --operations maintenance,retention,checkpoint\n",
356 );
357 out.push_str(" red auth create-user alice --password secret --role admin\n");
358 out.push_str(" red auth create-api-key alice --name \"ci-token\" --role write\n");
359 out.push_str(" red auth list-users\n");
360 out.push_str(" red auth login alice --password secret\n");
361 out.push_str(" red connect 127.0.0.1:5050\n");
362 out.push_str(" red connect --query \"SELECT * FROM users\" 127.0.0.1:5050\n");
363 out.push('\n');
364
365 out.push_str("Run 'red <command> --help' for more information on a command.\n");
366 out
367}
368
369pub fn command_help_text(name: &str) -> Option<String> {
371 let cmds = all_commands();
372 let cmd = cmds.iter().find(|c| c.name == name)?;
373
374 let mut out = String::with_capacity(512);
375
376 out.push_str(&format!("red {} -- {}\n", cmd.name, cmd.summary));
377 out.push('\n');
378 out.push_str(&format!("Usage: {}\n", cmd.usage));
379 out.push('\n');
380
381 if !cmd.flags.is_empty() {
382 out.push_str("Flags:\n");
383 for flag in &cmd.flags {
384 let short_part = match flag.short {
385 Some(ch) => format!("-{}, ", ch),
386 None => " ".to_string(),
387 };
388 let value_part = if flag.expects_value {
389 format!(" <{}>", flag.long.to_uppercase())
390 } else {
391 String::new()
392 };
393 let label = format!("{}--{}{}", short_part, flag.long, value_part);
394 let padding = if label.len() < 24 {
395 24 - label.len()
396 } else {
397 2
398 };
399 let default_text = match &flag.default {
400 Some(d) => format!(" (default: {})", d),
401 None => String::new(),
402 };
403 out.push_str(&format!(
404 " {}{}{}{}\n",
405 label,
406 " ".repeat(padding),
407 flag.description,
408 default_text,
409 ));
410 }
411 out.push('\n');
412 }
413
414 Some(out)
415}
416
417fn server_flags() -> Vec<FlagSchema> {
422 vec![
423 FlagSchema::new("path")
424 .with_short('d')
425 .with_description("Persistent database file path (omit for in-memory)")
426 .with_default("./data/reddb.rdb"),
427 FlagSchema::new("bind").with_short('b').with_description(
428 "Bind address (host:port) for the routed front-door or legacy single-transport mode",
429 ),
430 FlagSchema::boolean("grpc").with_description("Enable the gRPC API"),
431 FlagSchema::boolean("http").with_description("Serve the HTTP API"),
432 FlagSchema::new("grpc-bind").with_description("Explicit gRPC bind address (host:port)"),
433 FlagSchema::new("http-bind").with_description("Explicit HTTP bind address (host:port)"),
434 FlagSchema::new("http-tls-bind")
435 .with_description("HTTPS bind address (host:port). Runs alongside --http-bind"),
436 FlagSchema::new("http-tls-cert").with_description("Path to HTTPS server certificate PEM"),
437 FlagSchema::new("http-tls-key").with_description("Path to HTTPS server private key PEM"),
438 FlagSchema::new("http-tls-client-ca")
439 .with_description("Path to PEM CA bundle for client cert verification (mTLS)"),
440 FlagSchema::new("wire-bind")
441 .with_description("Explicit wire bind address (host:port or unix:///path/to/socket)"),
442 FlagSchema::new("wire-tls-bind")
443 .with_description("Explicit wire TLS bind address (host:port)"),
444 FlagSchema::new("wire-tls-cert")
445 .with_description("Path to TLS certificate PEM for wire TLS"),
446 FlagSchema::new("wire-tls-key")
447 .with_description("Path to TLS private key PEM for wire TLS"),
448 FlagSchema::new("pg-bind").with_description(
449 "PostgreSQL wire protocol bind address (enables psql / JDBC / DBeaver clients)",
450 ),
451 FlagSchema::new("role")
452 .with_short('r')
453 .with_description("Replication role")
454 .with_choices(&["standalone", "primary", "replica"])
455 .with_default("standalone"),
456 storage_profile_flag(),
457 storage_packaging_flag(),
458 storage_preset_flag(),
459 FlagSchema::new("replica-count")
460 .with_description("Expected replica count for storage profile validation"),
461 FlagSchema::boolean("managed-backup")
462 .with_description("Declare managed backup for storage profile validation"),
463 FlagSchema::boolean("wal-retention")
464 .with_description("Declare WAL retention for storage profile validation"),
465 FlagSchema::new("primary-addr").with_description("Primary gRPC address for replica mode"),
466 FlagSchema::boolean("read-only").with_description("Open the database in read-only mode"),
467 FlagSchema::boolean("bounded-disk-residency").with_description(
468 "Opt into bounded disk residency for standalone single-file databases; upgrades the writer format",
469 ),
470 FlagSchema::boolean("no-create-if-missing")
471 .with_description(
472 "Refuse to start unless --path already holds a store (env REDDB_NO_CREATE_IF_MISSING)",
473 ),
474 FlagSchema::boolean("auth").with_description("Enable authentication for this boot"),
475 FlagSchema::boolean("require-auth")
476 .with_description("Reject anonymous requests; implies --auth"),
477 FlagSchema::boolean("vault")
478 .with_description("Enable encrypted auth vault (reserved pages in main .rdb file)"),
479 FlagSchema::boolean("no-auth").with_description(
480 "Hard-disable auth: anonymous access, ignores REDDB_USERNAME/PASSWORD/vault, \
481 prints a startup warning. Local-dev shortcut — NEVER use in production.",
482 ),
483 FlagSchema::boolean("dev")
484 .with_description("Alias for --no-auth (local development convenience)."),
485 FlagSchema::new("bootstrap-preset")
486 .with_description(
487 "First-boot preset. With --vault on a fresh --path, red server \
488 self-bootstraps the paged vault in place (no separate `red bootstrap`) \
489 then applies the preset and serves; a re-boot against the existing \
490 vault just serves (idempotent — no re-bootstrap, no new certificate).",
491 )
492 .with_choices(&["simple", "production", "regulated", "cloud"]),
493 FlagSchema::new("bootstrap-manifest").with_description(
494 "Path to manifest-driven first boot JSON. Applied once on a fresh database \
495 before serving; later boots observe bootstrap state and skip re-applying \
496 the manifest (idempotent).",
497 ),
498 FlagSchema::new("bootstrap-admin")
499 .with_description("First admin username for production/cloud bootstrap"),
500 FlagSchema::new("bootstrap-admin-password").with_description(
501 "First admin password (DEV ONLY; prefer --bootstrap-admin-password-file)",
502 ),
503 FlagSchema::new("bootstrap-admin-password-file")
504 .with_description("File containing first admin password"),
505 FlagSchema::new("cloud-head-admin")
506 .with_description("Cloud preset head/platform admin username"),
507 FlagSchema::new("cloud-head-admin-password").with_description(
508 "Cloud preset head/platform admin password (DEV ONLY; prefer file flag)",
509 ),
510 FlagSchema::new("cloud-head-admin-password-file")
511 .with_description("File containing cloud head admin password"),
512 FlagSchema::new("customer-admin").with_description("Cloud preset customer admin username"),
513 FlagSchema::new("customer-admin-password")
514 .with_description("Cloud preset customer admin password (DEV ONLY; prefer file flag)"),
515 FlagSchema::new("customer-admin-password-file")
516 .with_description("File containing cloud customer admin password"),
517 FlagSchema::new("bootstrap-cert-out").with_description(
518 "Write the first-boot unseal certificate to this file (e.g. /run/reddb/cert.pem) \
519 without emitting it to logs, so a distroless init can read it back for the next \
520 boot's REDDB_CERTIFICATE_FILE unseal. Written only on the bootstrap-creating boot; \
521 a re-boot against the existing vault does not rewrite it.",
522 ),
523 FlagSchema::boolean("ui")
524 .with_description("Serve the pinned red-ui bundle as static assets"),
525 FlagSchema::new("ui-dir").with_description("Directory containing the red-ui bundle"),
526 FlagSchema::new("workers")
527 .with_short('w')
528 .with_description("Worker thread count (default: auto-detect from CPUs)"),
529 FlagSchema::new("log-dir").with_description(
530 "Directory for rotating log files (defaults to the parent of --path / ./logs)",
531 ),
532 FlagSchema::new("log-level")
533 .with_description(
534 "Log level filter — trace / debug / info / warn / error, or a RUST_LOG expression",
535 )
536 .with_default("info"),
537 FlagSchema::new("log-format")
538 .with_description("Log output format")
539 .with_choices(&["pretty", "json"])
540 .with_default("pretty"),
541 FlagSchema::new("log-keep-days")
542 .with_description("Number of rotated log files to keep")
543 .with_default("14"),
544 FlagSchema::boolean("no-log-file")
545 .with_description("Disable rotating file logs (stderr only)"),
546 FlagSchema::new("http-max-handlers").with_description(
547 "Max admitted in-flight HTTP requests, including queued execution \
548 (env: REDDB_HTTP_MAX_HANDLERS; \
549 red.config: http.max_handlers; default: (2 x num_cpus).clamp(8, 256))",
550 ),
551 FlagSchema::new("http-execution-workers").with_description(
552 "Max buffered non-health HTTP engine calls executed concurrently; excess admitted \
553 requests wait FIFO (env: REDDB_HTTP_EXECUTION_WORKERS; \
554 red.config: http.execution_workers; default: num_cpus)",
555 ),
556 FlagSchema::new("http-handler-timeout-ms")
557 .with_description(
558 "Per-handler total-time budget in ms (env: REDDB_HTTP_HANDLER_TIMEOUT_MS; \
559 red.config: http.handler_timeout_ms)",
560 )
561 .with_default("30000"),
562 FlagSchema::new("http-retry-after-secs")
563 .with_description(
564 "Retry-After seconds on limiter 503 (env: REDDB_HTTP_RETRY_AFTER_SECS; \
565 red.config: http.retry_after_secs; clamped to [1, 30])",
566 )
567 .with_default("5"),
568 FlagSchema::new("http-max-inflight-per-principal").with_description(
569 "Max concurrent in-flight HTTP requests per principal; over-cap requests \
570 get a structured 429 (env: REDDB_HTTP_MAX_INFLIGHT_PER_PRINCIPAL; \
571 red.config: http.max_inflight_per_principal; 0 disables; default: \
572 min(64, max_handlers - 1))",
573 ),
574 ]
575}
576
577fn replica_flags() -> Vec<FlagSchema> {
578 vec![
579 FlagSchema::new("primary-addr")
580 .with_short('p')
581 .with_description("Primary gRPC address (e.g. http://primary:55055)"),
582 FlagSchema::new("path")
583 .with_short('d')
584 .with_description("Local replica database file path")
585 .with_default("./data/reddb.rdb"),
586 FlagSchema::new("bind").with_short('b').with_description(
587 "Bind address (host:port) for the routed front-door or legacy single-transport mode",
588 ),
589 FlagSchema::boolean("grpc").with_description("Enable the gRPC API"),
590 FlagSchema::boolean("http").with_description("Serve the HTTP API"),
591 FlagSchema::new("grpc-bind").with_description("Explicit gRPC bind address (host:port)"),
592 FlagSchema::new("http-bind").with_description("Explicit HTTP bind address (host:port)"),
593 FlagSchema::new("wire-bind")
594 .with_description("Explicit wire bind address (host:port or unix:///path/to/socket)"),
595 storage_profile_flag(),
596 storage_packaging_flag(),
597 storage_preset_flag(),
598 FlagSchema::new("replica-count")
599 .with_description("Expected replica count for storage profile validation"),
600 FlagSchema::boolean("managed-backup")
601 .with_description("Declare managed backup for storage profile validation"),
602 FlagSchema::boolean("wal-retention")
603 .with_description("Declare WAL retention for storage profile validation"),
604 FlagSchema::boolean("auth").with_description("Enable authentication for this boot"),
605 FlagSchema::boolean("require-auth")
606 .with_description("Reject anonymous requests; implies --auth"),
607 FlagSchema::boolean("vault")
608 .with_description("Enable encrypted auth vault (reserved pages in main .rdb file)"),
609 FlagSchema::boolean("no-auth")
610 .with_description("Hard-disable auth: anonymous access, ignores vault"),
611 ]
612}
613
614fn ui_flags() -> Vec<FlagSchema> {
615 vec![
616 FlagSchema::boolean("server")
617 .with_description("Force the browser-served bridge path (skip the desktop deep link)"),
618 FlagSchema::boolean("desktop").with_description(
619 "Force the desktop app via the redui:// deep link (no browser fallback)",
620 ),
621 FlagSchema::new("ui-dir").with_description(
622 "Directory to serve the UI bundle from (defaults to the built-in fixture)",
623 ),
624 FlagSchema::new("port")
625 .with_description("Loopback port for the bridge (0 / omit picks an ephemeral port)"),
626 FlagSchema::new("tls-ca").with_description(
627 "PEM CA bundle to trust for a reds:// target (on top of system roots)",
628 ),
629 FlagSchema::new("token").with_short('t').with_description(
630 "Bearer token (session/API key). Held by red and injected into the \
631 RedWire handshake — the UI never sees it (env: RED_UI_TOKEN)",
632 ),
633 FlagSchema::boolean("no-browser").with_description(
634 "Do not open the default browser (also honoured via RED_UI_NO_BROWSER)",
635 ),
636 ]
637}
638
639fn vcs_flags() -> Vec<FlagSchema> {
640 vec![
641 FlagSchema::new("path")
642 .with_short('d')
643 .with_description("Persistent database file path (omit for in-memory)"),
644 FlagSchema::new("connection")
645 .with_short('c')
646 .with_description("Connection id for workset scoping")
647 .with_default("1"),
648 FlagSchema::new("branch").with_description("Branch name (for log/checkout/merge)"),
649 FlagSchema::new("from").with_description("Source ref or commit (branch create / merge)"),
650 FlagSchema::new("to").with_description("Upper bound for log range"),
651 FlagSchema::new("author")
652 .with_description("Commit author name")
653 .with_default("reddb"),
654 FlagSchema::new("email")
655 .with_description("Commit author email")
656 .with_default("reddb@localhost"),
657 FlagSchema::new("message")
658 .with_short('m')
659 .with_description("Commit message"),
660 FlagSchema::new("limit")
661 .with_description("Max log entries")
662 .with_default("20"),
663 FlagSchema::new("mode")
664 .with_description("Reset mode: soft | mixed | hard")
665 .with_default("mixed"),
666 FlagSchema::boolean("ff-only").with_description("Merge only if fast-forward"),
667 FlagSchema::boolean("no-ff").with_description("Always create a merge commit"),
668 ]
669}
670
671fn service_flags() -> Vec<FlagSchema> {
672 vec![
673 FlagSchema::new("binary")
674 .with_description("Path to the red binary")
675 .with_default("/usr/local/bin/red"),
676 FlagSchema::new("service-name")
677 .with_description("systemd unit name")
678 .with_default("reddb"),
679 FlagSchema::new("user")
680 .with_description("Service user")
681 .with_default("reddb"),
682 FlagSchema::new("group")
683 .with_description("Service group")
684 .with_default("reddb"),
685 FlagSchema::new("path")
686 .with_short('d')
687 .with_description("Persistent database file path")
688 .with_default(reddb_file::DEFAULT_SERVICE_DATABASE_PATH),
689 FlagSchema::new("bind").with_short('b').with_description(
690 "Bind address (host:port) for the routed front-door or legacy single-transport mode",
691 ),
692 FlagSchema::boolean("grpc").with_description("Enable the gRPC API in the service"),
693 FlagSchema::boolean("http").with_description("Install an HTTP service"),
694 FlagSchema::new("grpc-bind").with_description("Explicit gRPC bind address (host:port)"),
695 FlagSchema::new("http-bind").with_description("Explicit HTTP bind address (host:port)"),
696 ]
697}
698
699fn query_flags() -> Vec<FlagSchema> {
700 vec![
701 FlagSchema::new("bind")
702 .with_short('b')
703 .with_description("Server address")
704 .with_default("0.0.0.0:6380"),
705 FlagSchema::new("path").with_description("Open a local .rdb file in embedded mode"),
706 FlagSchema::new("param")
707 .with_short('p')
708 .with_description("Positional parameter for $1, $2, ... (repeatable)"),
709 FlagSchema::new("param-type").with_description("Type override for the preceding --param"),
710 FlagSchema::new("format").with_description(
711 "Row output format for query results (table|json|ndjson|csv|tsv|toon)",
712 ),
713 FlagSchema::new("save")
714 .with_description("Persist an ephemeral data-file query session as a new .rdb file"),
715 FlagSchema::boolean("dry-run")
716 .with_description("Preview the statement via EXPLAIN without executing it"),
717 ]
718}
719
720fn insert_flags() -> Vec<FlagSchema> {
721 data_target_flags(Some('p'))
722}
723
724fn get_flags() -> Vec<FlagSchema> {
725 data_target_flags(Some('p'))
726}
727
728fn delete_flags() -> Vec<FlagSchema> {
729 data_target_flags(Some('p'))
730}
731
732fn health_flags() -> Vec<FlagSchema> {
733 vec![
734 FlagSchema::new("bind")
735 .with_short('b')
736 .with_description("Server address; defaults by transport"),
737 FlagSchema::boolean("grpc").with_description("Probe a gRPC listener (default transport)"),
738 FlagSchema::boolean("http").with_description("Probe an HTTP listener"),
739 ]
740}
741
742fn bootstrap_flags() -> Vec<FlagSchema> {
743 vec![
744 FlagSchema::new("path")
745 .with_short('d')
746 .with_description("Persistent database file path"),
747 FlagSchema::boolean("vault")
748 .with_description("Required: seal credentials in the encrypted vault"),
749 FlagSchema::new("username")
750 .with_short('u')
751 .with_description("Admin username (defaults to REDDB_USERNAME)"),
752 FlagSchema::new("password")
753 .with_description("Admin password (DEV ONLY; prefer --password-stdin)"),
754 FlagSchema::boolean("password-stdin")
755 .with_description("Read the admin password from stdin (one line)"),
756 FlagSchema::boolean("print-certificate")
757 .with_description("Print only the certificate to stdout"),
758 ]
759}
760
761fn doctor_flags() -> Vec<FlagSchema> {
762 vec![
763 FlagSchema::new("bind")
764 .with_description("HTTP address of the server to probe")
765 .with_default("127.0.0.1:5000"),
766 FlagSchema::new("token")
767 .with_description("Admin bearer token; defaults to RED_ADMIN_TOKEN env"),
768 FlagSchema::new("backup-age-warn-secs")
769 .with_description("Warn when last successful backup is older than N seconds")
770 .with_default("600"),
771 FlagSchema::new("backup-age-crit-secs")
772 .with_description("Critical when last successful backup is older than N seconds")
773 .with_default("3600"),
774 FlagSchema::new("wal-lag-warn")
775 .with_description("Warn when WAL archive lag exceeds N records")
776 .with_default("1000"),
777 FlagSchema::new("wal-lag-crit")
778 .with_description("Critical when WAL archive lag exceeds N records")
779 .with_default("10000"),
780 ]
781}
782
783fn dump_flags() -> Vec<FlagSchema> {
784 vec![
785 FlagSchema::new("path")
786 .with_description("Local database file to dump from")
787 .with_default("./data/reddb.rdb"),
788 storage_profile_flag(),
789 storage_packaging_flag(),
790 storage_preset_flag(),
791 FlagSchema::new("collection")
792 .with_short('c')
793 .with_description("Single collection to dump (omit for all)"),
794 FlagSchema::new("output")
795 .with_short('o')
796 .with_description("Destination file (defaults to stdout)"),
797 ]
798}
799
800fn restore_flags() -> Vec<FlagSchema> {
801 vec![
802 FlagSchema::new("path")
803 .with_description("Local database file to restore into")
804 .with_default("./data/reddb.rdb"),
805 storage_profile_flag(),
806 storage_packaging_flag(),
807 storage_preset_flag(),
808 FlagSchema::boolean("bounded-disk-residency")
809 .with_description("Keep restored rows within the resolved memory budget"),
810 FlagSchema::new("input")
811 .with_short('i')
812 .with_description("Dump file to read (required)"),
813 FlagSchema::new("collection")
814 .with_short('c')
815 .with_description("Override target collection name"),
816 ]
817}
818
819fn pitr_list_flags() -> Vec<FlagSchema> {
820 vec![
821 FlagSchema::new("snapshot-prefix")
822 .with_description("Directory (or remote prefix) holding .snapshot files"),
823 FlagSchema::new("wal-prefix")
824 .with_description("Directory (or remote prefix) holding archived WAL segments"),
825 ]
826}
827
828fn pitr_restore_flags() -> Vec<FlagSchema> {
829 vec![
830 FlagSchema::new("target-time")
831 .with_description("Recovery target — UNIX ms (0 = latest available)"),
832 FlagSchema::new("dest")
833 .with_description("Destination database file path for the restored DB"),
834 FlagSchema::new("snapshot-prefix")
835 .with_description("Directory (or remote prefix) holding .snapshot files"),
836 FlagSchema::new("wal-prefix")
837 .with_description("Directory (or remote prefix) holding archived WAL segments"),
838 ]
839}
840
841fn tick_flags() -> Vec<FlagSchema> {
842 vec![
843 FlagSchema::new("bind")
844 .with_short('b')
845 .with_description("Server HTTP bind address")
846 .with_default("127.0.0.1:5000"),
847 FlagSchema::new("operations")
848 .with_description("Comma-separated operations: maintenance,retention,checkpoint"),
849 FlagSchema::boolean("dry-run")
850 .with_description("Validate operations without applying changes"),
851 ]
852}
853
854fn migrate_from_redis_flags() -> Vec<FlagSchema> {
855 vec![
856 FlagSchema::boolean("dry-run")
857 .with_description("Validate Redis and RedDB connectivity without cache writes"),
858 FlagSchema::new("redis-url")
859 .with_description("Redis URL to validate, for example redis://127.0.0.1:6379/0"),
860 FlagSchema::new("path")
861 .with_short('d')
862 .with_description("Local RedDB .rdb file to open for connectivity validation"),
863 FlagSchema::new("phase")
864 .with_description("Migration phase: dry-run | dual-write")
865 .with_default("dry-run"),
866 FlagSchema::new("namespace")
867 .with_description("Blob Cache namespace recorded in dry-run output")
868 .with_default("redis-migration"),
869 ]
870}
871
872fn migrate_pager_zone_flags() -> Vec<FlagSchema> {
873 vec![FlagSchema::new("path")
874 .with_short('d')
875 .with_description("Closed legacy sidecar-backed .rdb file to convert")]
876}
877
878fn salvage_flags() -> Vec<FlagSchema> {
879 vec![
880 FlagSchema::new("source").with_description("Damaged source .rdb file to read"),
881 FlagSchema::new("destination").with_description("Fresh destination .rdb file to create"),
882 ]
883}
884
885fn status_flags() -> Vec<FlagSchema> {
886 data_target_flags(Some('p'))
887}
888
889fn inspect_flags() -> Vec<FlagSchema> {
890 vec![
891 FlagSchema::new("path")
892 .with_short('d')
893 .with_description("Path to the on-disk database file"),
894 FlagSchema::new("at")
895 .with_description("Catalog at snapshot sequence (requires metadata journal)"),
896 ]
897}
898
899fn mcp_flags() -> Vec<FlagSchema> {
900 vec![
901 FlagSchema::new("uri")
902 .with_description("Connection URI (overrides --url and REDDB_MCP_URI)"),
903 FlagSchema::new("path")
904 .with_short('d')
905 .with_description("Data directory path (omit for in-memory)")
906 .with_default(""),
907 FlagSchema::new("url")
908 .with_description("Remote or embedded MCP connection URI; overrides REDDB_MCP_URI"),
909 FlagSchema::new("token")
910 .with_description("Bearer token fallback when --url has no userinfo"),
911 FlagSchema::boolean("allow-write")
916 .with_description("Permit tools and statements that modify data or schema"),
917 FlagSchema::boolean("allow-admin")
918 .with_description("Permit vault and auth tools (implies --allow-write)"),
919 ]
920}
921
922fn acp_flags() -> Vec<FlagSchema> {
923 vec![FlagSchema::new("path")
924 .with_short('d')
925 .with_description("Path to the embedded database file (omit for in-memory)")
926 .with_default("")]
927}
928
929fn connect_flags() -> Vec<FlagSchema> {
930 vec![
931 FlagSchema::new("token")
932 .with_short('t')
933 .with_description("Auth token (session or API key)"),
934 FlagSchema::new("query")
935 .with_short('q')
936 .with_description("Execute a single query and exit"),
937 FlagSchema::new("user")
938 .with_short('u')
939 .with_description("Username for login"),
940 FlagSchema::new("password")
941 .with_short('p')
942 .with_description("Password for login"),
943 ]
944}
945
946fn auth_flags() -> Vec<FlagSchema> {
947 vec![
948 FlagSchema::new("bind")
949 .with_short('b')
950 .with_description("Server address")
951 .with_default("0.0.0.0:6380"),
952 FlagSchema::new("password")
953 .with_short('p')
954 .with_description("User password"),
955 FlagSchema::new("role")
956 .with_short('r')
957 .with_description("User role")
958 .with_choices(&["read", "write", "admin"]),
959 FlagSchema::new("name")
960 .with_short('n')
961 .with_description("API key name"),
962 FlagSchema::new("user")
963 .with_short('u')
964 .with_description("Target username"),
965 ]
966}
967
968fn admin_flags() -> Vec<FlagSchema> {
969 vec![
970 FlagSchema::new("bind")
971 .with_short('b')
972 .with_description("Server HTTP address")
973 .with_default("127.0.0.1:5000"),
974 FlagSchema::new("token")
975 .with_short('t')
976 .with_description("Admin bearer token (env: RED_ADMIN_TOKEN)"),
977 FlagSchema::boolean("csv").with_description("Emit CSV for tabular admin catalog commands"),
978 FlagSchema::new("limit").with_description("Max rows for list/stats/query commands"),
979 FlagSchema::new("type").with_description("Filter collections by model"),
980 FlagSchema::boolean("include-internal").with_description("Include internal collections"),
981 FlagSchema::new("collection").with_description("Filter by collection"),
982 FlagSchema::boolean("yes")
983 .with_short('y')
984 .with_description("Skip destructive-command confirmation"),
985 FlagSchema::boolean("if-exists")
986 .with_description("Suppress errors for a missing collection"),
987 ]
988}
989
990fn rpc_flags() -> Vec<FlagSchema> {
991 vec![
992 FlagSchema::boolean("stdio")
993 .with_description("Speak JSON-RPC 2.0 line-delimited over stdin/stdout"),
994 FlagSchema::boolean("memory").with_description("Open a database in RAM"),
995 FlagSchema::boolean("temporary").with_description("Open a temporary database file"),
996 FlagSchema::new("path")
997 .with_short('d')
998 .with_description("Persistent database file path"),
999 FlagSchema::new("connect")
1000 .with_short('c')
1001 .with_description("Proxy to a remote gRPC server"),
1002 FlagSchema::new("token")
1003 .with_short('t')
1004 .with_description("Auth token forwarded to the remote server"),
1005 ]
1006}
1007
1008fn data_target_flags(path_short: Option<char>) -> Vec<FlagSchema> {
1009 let path = FlagSchema::new("path").with_description("Open a local .rdb file in embedded mode");
1010 let path = match path_short {
1011 Some(short) => path.with_short(short),
1012 None => path,
1013 };
1014 vec![
1015 FlagSchema::new("bind")
1016 .with_short('b')
1017 .with_description("Server address")
1018 .with_default("0.0.0.0:6380"),
1019 path,
1020 ]
1021}
1022
1023fn storage_profile_flag() -> FlagSchema {
1024 FlagSchema::new("storage-profile")
1025 .with_description("Storage deploy profile")
1026 .with_choices(&["embedded", "serverless", "primary-replica", "cluster"])
1027}
1028
1029fn storage_packaging_flag() -> FlagSchema {
1030 FlagSchema::new("storage-packaging")
1031 .with_description("Storage packaging contract")
1032 .with_choices(&["single-file", "operational-directory"])
1033}
1034
1035fn storage_preset_flag() -> FlagSchema {
1036 FlagSchema::new("storage-preset")
1037 .with_description("Storage/deploy preset")
1038 .with_choices(&[
1039 "embedded",
1040 "serverless",
1041 "primary-replica-dev",
1042 "primary-replica-small",
1043 "primary-replica-production-ha",
1044 "primary-replica-backup",
1045 "primary-replica-wal-retention",
1046 "cluster",
1047 ])
1048}
1049
1050pub fn completion_domains() -> Vec<(String, Vec<String>)> {
1056 vec![
1057 ("server".to_string(), vec![]),
1058 ("service".to_string(), vec![]),
1059 ("replica".to_string(), vec![]),
1060 ("tick".to_string(), vec![]),
1061 ("query".to_string(), vec!["q".to_string()]),
1062 ("insert".to_string(), vec!["i".to_string()]),
1063 ("get".to_string(), vec![]),
1064 ("delete".to_string(), vec!["del".to_string()]),
1065 ("health".to_string(), vec![]),
1066 ("status".to_string(), vec![]),
1067 ("inspect".to_string(), vec![]),
1068 ("migrate-from-redis".to_string(), vec![]),
1069 ("salvage".to_string(), vec![]),
1070 ("compact".to_string(), vec![]),
1071 ("recover-paged-wal".to_string(), vec![]),
1072 ("scrub-paged-trees".to_string(), vec![]),
1073 ("scrub-paged".to_string(), vec![]),
1074 ("salvage-paged-indexes".to_string(), vec![]),
1075 ("salvage-paged-collections".to_string(), vec![]),
1076 ("mcp".to_string(), vec![]),
1077 ("acp".to_string(), vec![]),
1078 ("auth".to_string(), vec![]),
1079 ("connect".to_string(), vec![]),
1080 ("version".to_string(), vec![]),
1081 ]
1082}
1083
1084pub fn completion_global_flags() -> Vec<(&'static str, Option<char>)> {
1086 vec![
1087 ("help", Some('h')),
1088 ("json", Some('j')),
1089 ("output", Some('o')),
1090 ("verbose", Some('v')),
1091 ("no-color", None),
1092 ("version", None),
1093 ]
1094}
1095
1096#[cfg(test)]
1097mod tests {
1098 use super::*;
1099
1100 #[test]
1101 fn test_all_commands_defined() {
1102 let cmds = all_commands();
1103 let names: Vec<&str> = cmds.iter().map(|c| c.name).collect();
1104 assert!(names.contains(&"server"));
1105 assert!(names.contains(&"query"));
1106 assert!(names.contains(&"insert"));
1107 assert!(names.contains(&"get"));
1108 assert!(names.contains(&"delete"));
1109 assert!(names.contains(&"health"));
1110 assert!(names.contains(&"tick"));
1111 assert!(names.contains(&"migrate-from-redis"));
1112 assert!(names.contains(&"salvage"));
1113 assert!(names.contains(&"status"));
1114 assert!(names.contains(&"inspect"));
1115 assert!(names.contains(&"connect"));
1116 assert!(names.contains(&"version"));
1117 }
1118
1119 #[test]
1120 fn test_inspect_has_flags() {
1121 let cmds = all_commands();
1122 let inspect = cmds.iter().find(|c| c.name == "inspect").unwrap();
1123 let flag_names: Vec<&str> = inspect.flags.iter().map(|f| f.long.as_str()).collect();
1124 assert!(flag_names.contains(&"path"));
1125 assert!(flag_names.contains(&"at"));
1126 }
1127
1128 #[test]
1129 fn test_server_has_flags() {
1130 let cmds = all_commands();
1131 let server = cmds.iter().find(|c| c.name == "server").unwrap();
1132 let flag_names: Vec<&str> = server.flags.iter().map(|f| f.long.as_str()).collect();
1133 assert!(flag_names.contains(&"path"));
1134 assert!(flag_names.contains(&"bind"));
1135 assert!(flag_names.contains(&"http-max-handlers"));
1137 assert!(flag_names.contains(&"http-execution-workers"));
1138 assert!(flag_names.contains(&"http-handler-timeout-ms"));
1139 assert!(flag_names.contains(&"http-retry-after-secs"));
1140 }
1141
1142 #[test]
1143 fn test_server_help_text_lists_http_limit_flags() {
1144 let help = command_help_text("server").unwrap();
1145 assert!(help.contains("--http-max-handlers"));
1146 assert!(help.contains("--http-execution-workers"));
1147 assert!(help.contains("--http-handler-timeout-ms"));
1148 assert!(help.contains("--http-retry-after-secs"));
1149 assert!(help.contains("REDDB_HTTP_MAX_HANDLERS"));
1150 assert!(help.contains("REDDB_HTTP_EXECUTION_WORKERS"));
1151 }
1152
1153 #[test]
1154 fn test_replica_has_flags() {
1155 let cmds = all_commands();
1156 let replica = cmds.iter().find(|c| c.name == "replica").unwrap();
1157 let flag_names: Vec<&str> = replica.flags.iter().map(|f| f.long.as_str()).collect();
1158 assert!(flag_names.contains(&"primary-addr"));
1159 assert!(flag_names.contains(&"path"));
1160 assert!(flag_names.contains(&"bind"));
1161 }
1162
1163 #[test]
1164 fn test_main_help_text() {
1165 let help = main_help_text();
1166 assert!(help.contains("reddb"));
1167 assert!(help.contains("Usage: red"));
1168 assert!(help.contains("Commands:"));
1169 assert!(help.contains("server"));
1170 assert!(help.contains("query"));
1171 assert!(help.contains("Global flags:"));
1172 assert!(help.contains("--help"));
1173 assert!(help.contains("Examples:"));
1174 }
1175
1176 #[test]
1177 fn test_command_help_text() {
1178 let help = command_help_text("server").unwrap();
1179 assert!(help.contains("red server"));
1180 assert!(help.contains("--path"));
1181 assert!(help.contains("--bind"));
1182 }
1183
1184 #[test]
1185 fn test_replica_command_help() {
1186 let help = command_help_text("replica").unwrap();
1187 assert!(help.contains("red replica"));
1188 assert!(help.contains("--primary-addr"));
1189 }
1190
1191 #[test]
1192 fn test_migrate_from_redis_command_help() {
1193 let help = command_help_text("migrate-from-redis").unwrap();
1194 assert!(help.contains("red migrate-from-redis"));
1195 assert!(help.contains("--dry-run"));
1196 assert!(help.contains("--redis-url"));
1197 assert!(help.contains("application-owned helper"));
1198 }
1199
1200 #[test]
1201 fn test_migrate_pager_zone_command_help() {
1202 let help = command_help_text("migrate-pager-zone").unwrap();
1203 assert!(help.contains("red migrate-pager-zone"));
1204 assert!(help.contains("--path"));
1205 assert!(help.contains("legacy sidecar-backed"));
1206 }
1207
1208 #[test]
1209 fn test_command_help_text_unknown() {
1210 assert!(command_help_text("nonexistent").is_none());
1211 }
1212
1213 #[test]
1214 fn test_flag_builder() {
1215 let flag = Flag::new("output", "Output format")
1216 .with_short('o')
1217 .with_default("text")
1218 .with_arg("FORMAT");
1219
1220 assert_eq!(flag.long, "output");
1221 assert_eq!(flag.short, Some('o'));
1222 assert_eq!(flag.description, "Output format");
1223 assert_eq!(flag.default, Some("text".to_string()));
1224 assert_eq!(flag.arg, Some("FORMAT".to_string()));
1225 }
1226
1227 #[test]
1228 fn test_completion_domains() {
1229 let domains = completion_domains();
1230 let names: Vec<&str> = domains.iter().map(|(n, _)| n.as_str()).collect();
1231 assert!(names.contains(&"server"));
1232 assert!(names.contains(&"query"));
1233 assert!(names.contains(&"health"));
1234 }
1235
1236 #[test]
1237 fn test_completion_global_flags() {
1238 let flags = completion_global_flags();
1239 assert!(flags.contains(&("help", Some('h'))));
1240 assert!(flags.contains(&("json", Some('j'))));
1241 assert!(flags.contains(&("verbose", Some('v'))));
1242 assert!(flags.contains(&("no-color", None)));
1243 }
1244}