fix: render help for <group> help subcommand form#15
Merged
Conversation
The engine ships a curated root `help` command and disables clap's auto-generated help subcommand on the root. In clap v4 that setting propagates to every subcommand and cannot be re-enabled per child, so `<group> help` (e.g. `gddy auth help`) was rejected — even though the group's help listing advertises a `help` entry. A pre-flight check also reported the `help` token as an unknown command before clap ran. Detect the `<group> help [sub...]` form in `Cli::run` and render the target's help directly, reusing the curated help-rendering path via a shared `render_help_for_parts` helper. Scoped to groups (pure subcommand dispatch); leaf commands are left to clap so a literal `help` argument still parses, and `<leaf> --help` is unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a mismatch between the CLI’s curated root help command and clap v4’s propagated disable_help_subcommand(true) behavior by detecting the <group> help [sub...] form at runtime and directly rendering the appropriate help output (equivalent to help <group> [sub...]), plus adds regression coverage.
Changes:
- Add a preflight detector for
<group> help [sub...]and route it to a sharedrender_help_for_partshelper. - Refactor root
help <path>rendering to reuse the new shared helper. - Add a tokio integration test covering
<group> helpand<group> help <sub>.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/cli.rs |
Adds group-help detection in Cli::run, introduces render_help_for_parts, and implements group_help_target_parts. |
tests/foundation.rs |
Adds regression test ensuring <group> help and <group> help <sub> render the expected help output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Route `<group> help` through the curated root `help` command (rewrite to `help <group> [sub...]`) so global-flag parsing and the `pre_run` hook run, matching `help <group>` and bare-group help. - Defer to clap when a group defines its own real `help` subcommand, so a consumer-registered `help` command is dispatched instead of the shim. - Compute the positional command path once and share it between the group-help rewrite and the unknown-command check. - Reword the test comment to describe the engine-level help shim accurately (the root suppresses clap's auto-generated help subcommand). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The previous rewrite reconstructed the argument vector from the command path alone, dropping any global flags (e.g. `--output json`) so the invocation was not truly equivalent to `help <group>`. Rewrite the positional command tokens in place within the normalized clap args instead: only the positional stream is reordered (`[group, help, sub]` -> `[help, group, sub]`), while every flag — `key=value` forms, value-consuming flags, unknown flags that consume a value, and anything after `--` — is preserved in its original position. Add regression coverage for a global flag before the group and a `key=value` flag after. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Positional tokens after a `--` separator are literal operands, not command keywords, so the group-help shim must not treat a `help` among them as a help request. Previously `<group> -- help` rendered the group's help; now the `help` is left to clap as a literal (unknown) subcommand, matching the documented meaning of `--`. The guard counts the positionals preceding any `--` and only matches a `help` token before that boundary, so `<group> help -- <sub>` (help before the separator) still renders the subcommand's help.
Add coverage for `<group> <subgroup> help` and `<group> <subgroup> help <leaf>`, exercising the group-help shim's full prefix walk through a nested group.
jgowdy-godaddy
approved these changes
Jun 8, 2026
jpage-godaddy
pushed a commit
that referenced
this pull request
Jun 9, 2026
🤖 I have created a release *beep* *boop* --- ## [0.2.0](cli-engine-v0.1.3...cli-engine-v0.2.0) (2026-06-09) ### ⚠ BREAKING CHANGES * `CommandSpec.no_auth` (bool) is replaced by `CommandSpec.auth` (`AuthRequirement`), and `MiddlewareRequest.no_auth` by `MiddlewareRequest.auth`. `CommandContext.credential` is now a `CredentialResolver` instead of `Option<Credential>`; `RuntimeCommandSpec::new` and `new_typed` handler closures receive a `CredentialResolver`; and `Authorizer::authorize` receives `&CredentialResolver` instead of `Option<&Credential>`. The `no_auth(true)` builder still works and maps to `AuthRequirement::None`; `auth_optional()` and `auth(AuthRequirement)` select the other policies. ### Features * fail-closed authentication via AuthRequirement; populate PKCE identity ([#17](#17)) ([34313bf](34313bf)) ### Bug Fixes * render help for `<group> help` subcommand form ([#15](#15)) ([c21db13](c21db13)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<group> help(e.g.gddy auth help,gddy application help) was reported as broken: it returnedunknown command "help" for "gddy auth"even though the group's help listing advertises ahelpcommand.Root cause
The engine ships a curated root
helpcommand, so it calls.disable_help_subcommand(true)on the root. In clap v4 that setting propagates to every subcommand and cannot be re-enabled per child, so no group has a workinghelpsubcommand at parse time — yet the group help listing still shows one (it's rendered viarender_long_help(), which builds the group in isolation and re-addshelp). On top of that, a pre-flight check (unknown_group_command_message) reported thehelptoken as an unknown command before clap ran.Fix
Detect the
<group> help [sub...]form inCli::runand render the target's help directly, reusing the curated help-rendering path via a new sharedrender_help_for_partshelper. This matches clap's documented equivalence betweencmd group help subandcmd help group sub.Scoped to groups (pure subcommand dispatch, so a
helptoken there is unambiguously a help request). Leaf commands are left to clap so a literalhelppositional argument still parses, and<leaf> --helpis unaffected.Testing
cli_runtime_group_help_subcommand_renders_group_help(TDD: confirmed it fails before the fix, passes after). Covers<group> helpand<group> help <sub>.cargo fmt --check,clippy -D warnings,cargo doc -D warnings, full test suite + doctests all pass.gddyCLI (patched to this engine):gddy auth help,gddy application help, andgddy auth help statusall render help with exit 0; roothelp,help auth,auth login --help, and theauth bogusunknown-command error are unaffected.🤖 Generated with Claude Code