diff --git a/crates/registry-cli-docs/catalog.json b/crates/registry-cli-docs/catalog.json index 25d7901edc..3a56e9d819 100644 --- a/crates/registry-cli-docs/catalog.json +++ b/crates/registry-cli-docs/catalog.json @@ -1437,7 +1437,7 @@ }, { "display": "--print-sql", - "description": "Print the SQL script and connect to nothing", + "description": "Print the SQL script and connect to nothing. Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.", "always_required": false, "repeatable": false, "default_values": [], @@ -1469,7 +1469,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -2192,7 +2192,7 @@ }, { "display": "--print-sql", - "description": "Print the SQL script and connect to nothing", + "description": "Print the SQL script and connect to nothing. Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.", "always_required": false, "repeatable": false, "default_values": [], @@ -2224,7 +2224,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -6200,7 +6200,7 @@ }, { "display": "--print-sql", - "description": "Print the SQL script and connect to nothing", + "description": "Print the SQL script and connect to nothing. Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.", "always_required": false, "repeatable": false, "default_values": [], @@ -11628,7 +11628,7 @@ }, { "display": "--print-sql", - "description": "Print the SQL script and connect to nothing", + "description": "Print the SQL script and connect to nothing. Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.", "always_required": false, "repeatable": false, "default_values": [], @@ -11660,7 +11660,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -13342,7 +13342,7 @@ "name": "serve", "invocation": "coordinatorctl serve", "about": "Run the production Coordinator service with the selected runtime", - "long_about": null, + "long_about": "Run the production Coordinator service with the selected runtime. Supply `--runtime-config ` for the deployment. Omit `--format` to use the service output stream.", "usage": "coordinatorctl serve [OPTIONS]", "arguments": [], "options": [ @@ -13380,7 +13380,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -13591,7 +13591,7 @@ "name": "check", "invocation": "coordinatorctl check", "about": "Validate the workflow, Transforms and root YAML companions offline", - "long_about": null, + "long_about": "Validate the workflow, Transforms and root YAML companions offline. Supply `--project`, `--runtime-config`, or both. `--explain` requires `--project`.", "usage": "coordinatorctl check [OPTIONS]", "arguments": [], "options": [ @@ -13674,7 +13674,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -14180,7 +14180,7 @@ "name": "provision", "invocation": "coordinatorctl provision", "about": "Create the database, the migration and runtime roles, and the grants `apply` expects, as a PostgreSQL administrator", - "long_about": null, + "long_about": "Create the database, the migration and runtime roles, and the grants `apply` expects, as a PostgreSQL administrator. Supply `--runtime-config ` before or after `provision`.", "usage": "coordinatorctl provision [OPTIONS]", "arguments": [], "options": [ @@ -14204,7 +14204,7 @@ }, { "display": "--print-sql", - "description": "Print the SQL script and connect to nothing", + "description": "Print the SQL script and connect to nothing. Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.", "always_required": false, "repeatable": false, "default_values": [], @@ -14245,7 +14245,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -17256,7 +17256,7 @@ }, { "display": "--print-sql", - "description": "Print the SQL script and connect to nothing", + "description": "Print the SQL script and connect to nothing. Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.", "always_required": false, "repeatable": false, "default_values": [], @@ -17288,7 +17288,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -23752,7 +23752,7 @@ }, { "display": "--print-sql", - "description": "Print the SQL script and connect to nothing", + "description": "Print the SQL script and connect to nothing. Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.", "always_required": false, "repeatable": false, "default_values": [], @@ -23794,7 +23794,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -24921,7 +24921,7 @@ }, { "display": "--print-sql", - "description": "Print the SQL script and connect to nothing", + "description": "Print the SQL script and connect to nothing. Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.", "always_required": false, "repeatable": false, "default_values": [], @@ -24953,7 +24953,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -27989,9 +27989,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28059,9 +28059,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28120,9 +28120,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28178,7 +28178,7 @@ "name": "install", "invocation": "rstack install", "about": "Install one or more components at the selected release", - "long_about": null, + "long_about": "Install one or more components at the selected release. Select either one or more component names or `--all`.", "usage": "rstack install [OPTIONS] [COMPONENT]...", "arguments": [ { @@ -28203,9 +28203,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28244,7 +28244,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -28283,9 +28283,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28339,7 +28339,7 @@ "name": "uninstall", "invocation": "rstack uninstall", "about": "Remove one or more installed components", - "long_about": null, + "long_about": "Remove one or more installed components. Select either one or more component names or `--all`.", "usage": "rstack uninstall [OPTIONS] [COMPONENT]...", "arguments": [ { @@ -28364,9 +28364,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28405,7 +28405,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -28426,9 +28426,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28488,9 +28488,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28544,8 +28544,8 @@ "name": "help", "invocation": "rstack help", "about": "Show offline product help", - "long_about": null, - "usage": "help [PRODUCT]", + "long_about": "Show offline product help. Omit the product for the launcher overview. Use `rstack help dev` for local development help. For a specific product action, run `rstack --help`.", + "usage": "rstack help [OPTIONS] [PRODUCT]", "arguments": [ { "display": "[PRODUCT]", @@ -28557,43 +28557,12 @@ "environment": null } ], - "options": [ - { - "display": "-h, --help", - "description": "Print help", - "always_required": false, - "repeatable": false, - "default_values": [], - "possible_values": [], - "environment": null - } - ], - "constraints": [], - "subcommands": [] - }, - { - "name": "completions", - "invocation": "rstack completions", - "about": "Generate shell completion script", - "long_about": null, - "usage": "rstack completions [OPTIONS] ", - "arguments": [ - { - "display": "", - "description": "Shell whose completion script to generate", - "always_required": true, - "repeatable": false, - "default_values": [], - "possible_values": [], - "environment": null - } - ], "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28632,7 +28601,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], @@ -28653,9 +28622,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -28714,9 +28683,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -29135,9 +29104,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -29424,9 +29393,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -29488,9 +29457,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -29549,9 +29518,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -29639,9 +29608,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -29747,9 +29716,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -29819,9 +29788,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -29961,9 +29930,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -30064,9 +30033,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -30138,9 +30107,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -30250,9 +30219,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -30304,9 +30273,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -30358,9 +30327,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -30403,9 +30372,9 @@ "options": [ { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -30457,9 +30426,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -30529,9 +30498,9 @@ }, { "display": "--format ", - "description": "Report encoding. Defaults to human even when stdout is piped. Only forwarded evidence test and evidence fixtures run commands accept junit", + "description": "Report encoding. Defaults to human even when stdout is piped. Supply `--format` at most once. Only forwarded evidence test and evidence fixtures run commands accept junit", "always_required": false, - "repeatable": true, + "repeatable": false, "default_values": [ "human" ], @@ -30571,6 +30540,64 @@ "subcommands": [] } ] + }, + { + "name": "completions", + "invocation": "rstack completions", + "about": "Generate a Zsh completion script", + "long_about": "Generate a Zsh completion script. Run `rstack completions zsh` and omit `--format`.", + "usage": "rstack completions [OPTIONS] ", + "arguments": [ + { + "display": "", + "description": "Shell whose completion script to generate", + "always_required": true, + "repeatable": false, + "default_values": [], + "possible_values": [], + "environment": null + } + ], + "options": [ + { + "display": "--install-root ", + "description": "Installation generation storage directory", + "always_required": false, + "repeatable": false, + "default_values": [], + "possible_values": [], + "environment": null + }, + { + "display": "--bin-dir ", + "description": "Directory for the single public rstack executable link", + "always_required": false, + "repeatable": false, + "default_values": [], + "possible_values": [], + "environment": null + }, + { + "display": "--asset-dir ", + "description": "Directory of already downloaded, verified release assets", + "always_required": false, + "repeatable": false, + "default_values": [], + "possible_values": [], + "environment": null + }, + { + "display": "-h, --help", + "description": "Print help (see a summary with '-h')", + "always_required": false, + "repeatable": false, + "default_values": [], + "possible_values": [], + "environment": null + } + ], + "constraints": [], + "subcommands": [] } ] }, @@ -31840,7 +31867,7 @@ }, { "display": "--print-sql", - "description": "Print the SQL script and connect to nothing", + "description": "Print the SQL script and connect to nothing. Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.", "always_required": false, "repeatable": false, "default_values": [], @@ -31872,7 +31899,7 @@ }, { "display": "-h, --help", - "description": "Print help", + "description": "Print help (see a summary with '-h')", "always_required": false, "repeatable": false, "default_values": [], diff --git a/crates/registry-cli-docs/src/lib.rs b/crates/registry-cli-docs/src/lib.rs index 36970d92f9..df4ebde7be 100644 --- a/crates/registry-cli-docs/src/lib.rs +++ b/crates/registry-cli-docs/src/lib.rs @@ -89,7 +89,8 @@ fn breg_reference() -> CommandReference { /// The shared walker omits commands named `help` because Clap normally adds /// one synthetically, while `rstack` disables that command and defines its own. fn rstack_reference() -> CommandReference { - let command = registry_rstack::command(); + let mut command = registry_rstack::command(); + command.build(); let (help_index, help) = command .get_subcommands() .filter(|subcommand| !subcommand.is_hide_set()) @@ -102,9 +103,24 @@ fn rstack_reference() -> CommandReference { help_index, command_reference(help, Some(&reference.invocation), None), ); + limit_launcher_format_to_one(&mut reference); reference } +fn limit_launcher_format_to_one(command: &mut CommandReference) { + // The launcher rejects duplicate --format options before Clap parses them. + if let Some(format) = command + .options + .iter_mut() + .find(|option| option.display == "--format ") + { + format.repeatable = false; + } + for subcommand in &mut command.subcommands { + limit_launcher_format_to_one(subcommand); + } +} + /// The committed catalog snapshot the docs site renders, beside this crate's /// manifest. pub fn snapshot_path() -> PathBuf { @@ -288,12 +304,103 @@ mod tests { ] { assert!(!find_command(&catalog.binaries, invocation).usage.is_empty()); } - let root = find_command(&catalog.binaries, "rstack"); - assert!(root.options.iter().any(|option| { - option.display == "--format " - && option.default_values == ["human"] - && option.possible_values == ["human", "json"] - })); + for invocation in ["rstack", "rstack help", "rstack dev check"] { + let command = find_command(&catalog.binaries, invocation); + assert!( + command.options.iter().any(|option| { + option.display == "--format " + && !option.repeatable + && option.default_values == ["human"] + && option.possible_values == ["human", "json"] + }), + "{invocation}" + ); + } + let help = find_command(&catalog.binaries, "rstack help"); + assert_eq!(help.usage, "rstack help [OPTIONS] [PRODUCT]"); + for option in [ + "--install-root ", + "--bin-dir ", + "--asset-dir ", + "-h, --help", + ] { + assert!( + help.options + .iter() + .any(|argument| argument.display == option), + "{option}" + ); + } + let completions = find_command(&catalog.binaries, "rstack completions"); + assert!(!completions + .options + .iter() + .any(|option| option.display.starts_with("--format "))); + assert!(completions + .long_about + .as_deref() + .is_some_and(|about| about.contains("rstack completions zsh"))); + for invocation in ["rstack install", "rstack uninstall"] { + let command = find_command(&catalog.binaries, invocation); + assert!( + command.long_about.as_deref().is_some_and(|about| { + about.contains("one or more component names or `--all`") + }), + "{invocation}" + ); + } + } + + #[test] + fn provision_references_document_the_shared_mode_requirement() { + let catalog = catalog(); + for invocation in [ + "adapterctl provision", + "adapterctl job provision", + "coordinatorctl provision", + "documentsctl provision", + ] { + let command = find_command(&catalog.binaries, invocation); + assert!(command.options.iter().any(|option| { + option.display == "--print-sql" + && option.description.contains("Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`.") + }), "{invocation}"); + } + } + + #[test] + fn coordinator_reference_describes_execution_requirements() { + let catalog = catalog(); + for (verb, requirements) in [ + ( + "serve", + ["Supply `--runtime-config `", "Omit `--format`"], + ), + ( + "check", + [ + "`--project`, `--runtime-config`, or both", + "`--explain` requires `--project`", + ], + ), + ( + "provision", + [ + "Supply `--runtime-config `", + "before or after `provision`", + ], + ), + ] { + let invocation = format!("coordinatorctl {verb}"); + let command = find_command(&catalog.binaries, &invocation); + let description = command.long_about.as_deref().expect("command description"); + for requirement in requirements { + assert!( + description.contains(requirement), + "{invocation}: {description}" + ); + } + } } #[test] diff --git a/crates/registry-coordinator/src/cli.rs b/crates/registry-coordinator/src/cli.rs index 865c1d55a0..81cffaa9b5 100644 --- a/crates/registry-coordinator/src/cli.rs +++ b/crates/registry-coordinator/src/cli.rs @@ -136,6 +136,8 @@ enum Command { command: registry_cli_api::ConnectionCommand, }, /// Run the production Coordinator service with the selected runtime. + /// + /// Supply `--runtime-config ` for the deployment. Omit `--format` to use the service output stream. Serve { /// Coordinator runtime executable for an unmanaged installation. #[arg(long, hide = true, env = "COORDINATOR_BIN", value_name = "BINARY")] @@ -156,6 +158,8 @@ enum Command { topic: GenerateTopic, }, /// Validate the workflow, Transforms and root YAML companions offline. + /// + /// Supply `--project`, `--runtime-config`, or both. `--explain` requires `--project`. Check { #[arg(long)] /// Directory containing workflow.yaml and its declared code and contract assets. @@ -228,6 +232,8 @@ enum Command { remove_workflow: Vec, }, /// Create the database, the migration and runtime roles, and the grants `apply` expects, as a PostgreSQL administrator. + /// + /// Supply `--runtime-config ` before or after `provision`. #[command(mut_arg("runtime_config", |argument| argument.required(false)))] Provision(registry_platform_provision::cli::ProvisionArgs), /// Apply every listed workflow's package and least-privileged runtime grants using migration credentials. diff --git a/crates/registry-coordinator/tests/cli_authoring.rs b/crates/registry-coordinator/tests/cli_authoring.rs index fc36973895..67062974a4 100644 --- a/crates/registry-coordinator/tests/cli_authoring.rs +++ b/crates/registry-coordinator/tests/cli_authoring.rs @@ -11,6 +11,38 @@ fn cli(arguments: &[&str]) -> std::process::Output { .unwrap() } +#[test] +fn serve_help_documents_the_runtime_file_and_stream_requirements() { + let output = cli(&["serve", "--help"]); + assert!(output.status.success(), "{output:?}"); + assert!(output.stderr.is_empty(), "{output:?}"); + let help = String::from_utf8(output.stdout).unwrap(); + assert!(help.contains("Supply `--runtime-config `"), "{help}"); + assert!(help.contains("Omit `--format`"), "{help}"); + + for (arguments, diagnostic) in [ + (&["serve"][..], "serve requires --runtime-config"), + ( + &[ + "serve", + "--runtime-config", + "unused.yaml", + "--format", + "human", + ], + "--format does not apply to serve", + ), + ] { + let output = cli(arguments); + assert_eq!(output.status.code(), Some(2), "{output:?}"); + assert!(output.stdout.is_empty(), "{output:?}"); + assert!( + String::from_utf8_lossy(&output.stderr).contains(diagnostic), + "{output:?}" + ); + } +} + #[test] fn runtime_check_is_offline_until_environment_is_explicitly_requested() { let root = tempfile::tempdir().unwrap(); diff --git a/crates/registry-platform-provision/src/cli.rs b/crates/registry-platform-provision/src/cli.rs index 2ac7f4548e..efde049061 100644 --- a/crates/registry-platform-provision/src/cli.rs +++ b/crates/registry-platform-provision/src/cli.rs @@ -63,7 +63,9 @@ pub struct ProvisionArgs { required_unless_present_any = ["admin_url_file", "print_sql"] )] pub admin_url_env: Option, - /// Print the SQL script and connect to nothing + /// Print the SQL script and connect to nothing. + /// + /// Choose exactly one of `--admin-url-file`, `--admin-url-env`, or `--print-sql`. #[arg(long)] pub print_sql: bool, /// Declared posture: development or production. Unset means production. diff --git a/crates/registry-rstack/src/cli.rs b/crates/registry-rstack/src/cli.rs index 7d0936cfe1..578ba563a2 100644 --- a/crates/registry-rstack/src/cli.rs +++ b/crates/registry-rstack/src/cli.rs @@ -71,6 +71,7 @@ enum RequestedReportFormat { )] struct Cli { /// Report encoding. Defaults to human even when stdout is piped. + /// Supply `--format` at most once. /// Only forwarded evidence test and evidence fixtures run commands accept junit. #[arg(long, global = true, value_enum, action = ArgAction::Append, default_value = "human")] format: Vec, @@ -113,6 +114,8 @@ enum Command { command: ComponentCommand, }, /// Install one or more components at the selected release. + /// + /// Select either one or more component names or `--all`. Install { /// Install every product available for the selected platform. #[arg(long)] @@ -131,6 +134,8 @@ enum Command { preview: bool, }, /// Remove one or more installed components. + /// + /// Select either one or more component names or `--all`. Uninstall { /// Remove the complete managed installation. #[arg(long)] @@ -144,12 +149,17 @@ enum Command { /// Check selected binaries, paths, and component availability. Doctor, /// Show offline product help. + /// + /// Omit the product for the launcher overview. Use `rstack help dev` for local development help. + /// For a specific product action, run `rstack --help`. Help { /// Product whose offline command reference to show. #[arg(value_name = "PRODUCT")] product: Option, }, - /// Generate shell completion script. + /// Generate a Zsh completion script. + /// + /// Run `rstack completions zsh` and omit `--format`. Completions { /// Shell whose completion script to generate. #[arg(value_name = "SHELL")] @@ -671,11 +681,11 @@ enum ComponentCommand { List, } -/// The installer's global path flags mean nothing to a development run, so -/// `dev` and its subcommands carry hidden copies that keep them out of their -/// help while still accepting them. +/// Build the launcher tree with help tailored to each command. Development +/// hides the installer's path flags. Completions hides the report format flag +/// so the handler can still give its dedicated refusal when it is supplied. pub fn command() -> clap::Command { - Cli::command().mut_subcommand("dev", |dev| { + let command = Cli::command().mut_subcommand("dev", |dev| { [ ("install_root", "install-root"), ("bin_dir", "bin-dir"), @@ -691,6 +701,14 @@ pub fn command() -> clap::Command { .value_parser(value_parser!(PathBuf)), ) }) + }); + let format = command + .get_arguments() + .find(|argument| argument.get_id() == "format") + .expect("the launcher has a global report format") + .clone(); + command.mut_subcommand("completions", |completions| { + completions.arg(format.hide(true)) }) } diff --git a/crates/registry-rstack/tests/cli.rs b/crates/registry-rstack/tests/cli.rs index 6ca924cf3b..a8625d1954 100644 --- a/crates/registry-rstack/tests/cli.rs +++ b/crates/registry-rstack/tests/cli.rs @@ -40,6 +40,50 @@ fn root_help_works_without_an_installation() { assert!(text.contains("evidence")); } +#[test] +fn offline_help_command_shows_its_own_invocation_and_global_options() { + let output = run(&["help", "--help"]); + assert!(output.status.success(), "{output:?}"); + assert!(output.stderr.is_empty(), "{output:?}"); + let help = String::from_utf8(output.stdout).unwrap(); + assert!( + help.contains("Usage: rstack help [OPTIONS] [PRODUCT]"), + "{help}" + ); + for option in [ + "--format", + "--install-root", + "--bin-dir", + "--asset-dir", + "--help", + ] { + assert!(help.contains(option), "{help}"); + } +} + +#[test] +fn installation_commands_document_and_enforce_the_component_selection() { + for verb in ["install", "uninstall"] { + let output = run(&[verb, "--help"]); + assert!(output.status.success(), "{output:?}"); + assert!(output.stderr.is_empty(), "{output:?}"); + let help = String::from_utf8(output.stdout).unwrap(); + assert!( + help.contains("one or more component names or `--all`"), + "{help}" + ); + + for arguments in [vec![verb], vec![verb, "breg", "--all"]] { + let output = run(&arguments); + assert_eq!(output.status.code(), Some(2), "{output:?}"); + assert!(output.stdout.is_empty(), "{output:?}"); + assert!( + String::from_utf8_lossy(&output.stderr).contains("select component names or --all") + ); + } + } +} + #[test] fn unknown_component_and_duplicate_format_are_usage_failures() { let unknown = run(&["install", "bogus"]); @@ -67,6 +111,13 @@ fn unknown_component_and_duplicate_format_are_usage_failures() { #[test] fn completions_refuses_an_explicit_report_format_without_emitting_a_script() { + let output = run(&["completions", "--help"]); + assert!(output.status.success(), "{output:?}"); + assert!(output.stderr.is_empty(), "{output:?}"); + let help = String::from_utf8(output.stdout).unwrap(); + assert!(help.contains("rstack completions zsh"), "{help}"); + assert!(!help.contains("--format "), "{help}"); + let before = run(&["--format", "human", "completions", "zsh"]); assert_eq!(before.status.code(), Some(2), "{before:?}"); assert!(before.stdout.is_empty(), "{before:?}"); diff --git a/docs/site/scripts/cli-reference-sidebar.test.mjs b/docs/site/scripts/cli-reference-sidebar.test.mjs index 357de2dd22..67693529d5 100644 --- a/docs/site/scripts/cli-reference-sidebar.test.mjs +++ b/docs/site/scripts/cli-reference-sidebar.test.mjs @@ -66,6 +66,32 @@ test('seats every published command page in command order', async (t) => { ]); }); +test('seats the launcher and its nested commands only when published', async (t) => { + const root = await mkdtemp(resolve(tmpdir(), 'registry-docs-cli-sidebar-')); + t.after(() => rm(root, { recursive: true, force: true })); + const index = resolve(root, 'index.mdx'); + + await writeFile(index, page('CLI reference')); + await mkdir(resolve(root, 'rstack/dev'), { recursive: true }); + await writeFile(resolve(root, 'rstack/dev.mdx'), page('rstack dev')); + await writeFile(resolve(root, 'rstack/dev/check.mdx'), page('rstack dev check')); + await writeFile(resolve(root, 'rstack/dev/run.mdx'), draftPage('rstack dev run')); + + const launcher = resolve(root, 'rstack.mdx'); + await writeFile(launcher, draftPage('rstack')); + assert.deepEqual(cliReferenceSidebar(index)[0].items, [ + { label: 'Overview', slug: 'reference/cli' }, + ]); + + await writeFile(launcher, page('rstack')); + assert.deepEqual(cliReferenceSidebar(index)[0].items, [ + { label: 'Overview', slug: 'reference/cli' }, + { label: 'rstack', slug: 'reference/cli/rstack' }, + { label: 'rstack dev', slug: 'reference/cli/rstack/dev' }, + { label: 'rstack dev check', slug: 'reference/cli/rstack/dev/check' }, + ]); +}); + test('omits every seat of a binary whose product the docset does not publish', async (t) => { const root = await mkdtemp(resolve(tmpdir(), 'registry-docs-cli-sidebar-')); t.after(() => rm(root, { recursive: true, force: true })); diff --git a/docs/site/src/lib/cli-reference-sidebar.mjs b/docs/site/src/lib/cli-reference-sidebar.mjs index 15f768c212..d34f14234c 100644 --- a/docs/site/src/lib/cli-reference-sidebar.mjs +++ b/docs/site/src/lib/cli-reference-sidebar.mjs @@ -8,6 +8,7 @@ const generatedIndex = new URL('../content/docs/reference/cli/index.mdx', import // docset built from an older catalog contains no pages for a binary that // catalog predates, and pages that do not exist receive no seat. const binaries = [ + 'rstack', 'breg', 'bregctl', 'breg-mcp', diff --git a/products/identifiers/generated/catalog.v1.json b/products/identifiers/generated/catalog.v1.json index 5a02ffbbcd..e526739dd8 100644 --- a/products/identifiers/generated/catalog.v1.json +++ b/products/identifiers/generated/catalog.v1.json @@ -6990,7 +6990,7 @@ "description": "Report of the shared `provision` command that creates a product's PostgreSQL roles, database, schemas and extensions.", "source": { "path": "crates/registry-platform-provision/src/cli.rs", - "sha256": "3227f9b61266f2771d56ea63c8b6d6853b2f3d9c8c53a90fcc69c829d4f20a12" + "sha256": "3a6084dd1408095fa804177ab3fc7deb09364c781fece96212caaa807da39ffd" }, "artifact": { "path": "crates/registry-platform-provision/schema/provision-report.schema.json", @@ -7062,7 +7062,7 @@ "description": "rstack error report JSON Schema.", "source": { "path": "crates/registry-rstack/src/cli.rs", - "sha256": "553b66d3c5bbd9d72b09481e3ff469572f81cf9b4ef87945ca06ea2ad0e12a53" + "sha256": "42085df192cf6ef31b76a71028c6ab2ae778da4a4552f0880a52a0993a9cb11c" }, "artifact": { "path": "products/platform/schemas/rstack-dev-error.v1.schema.json",