chore(cli): remove clap's auto-generated help subcommand #120

Merged
Claude-Run merged 1 commit from chore/YT-63-remove-help-subcommand into main 2026-07-17 12:44:22 +02:00
Member

--help / -h is now the one spelling for help. clap injected a help subcommand into every command built from a subcommand enum, rendering identical output through the same code path as the flag. The redundancy was conditional and therefore worse than plain redundancy: help worked on branch commands but was rejected as a stray positional on leaves, so the reader had to already know a command's shape to know whether the second spelling applied to it.

Add cli::yt_command() as the one constructor for the clap command tree. It walks the tree and calls disable_help_subcommand(true) at every level, which is required because the setting is per-command and does not propagate from the root. main.rs parses through it via Cli::from_arg_matches instead of Cli::parse(), and completions.rs generates through it as well, so no generated completion script offers a spelling the binary rejects. -h / --help are a separate mechanism and are untouched; yt help now fails with clap's unrecognized-subcommand error, which points at --help and fails the same way on branches and leaves alike.

Three tests cover it: a tree walk asserting every subcommand-bearing command has the setting, a behavior test that yt help / yt config help / yt mcp secret help are rejected rather than printing help, and one pinning --help / -h. The walk asserts the setting rather than searching for an injected help in get_subcommands(), because clap injects it lazily during Command::build() and an unbuilt tree never shows it. Calling build() in the test is not possible today: it runs clap's debug asserts over the whole tree and yt list trips one by binding -q to both the global --quiet and its own --query. That is a real pre-existing bug, out of scope here, and is recorded for a follow-up issue.

#YT-63

`--help` / `-h` is now the one spelling for help. clap injected a `help` subcommand into every command built from a subcommand enum, rendering identical output through the same code path as the flag. The redundancy was conditional and therefore worse than plain redundancy: `help` worked on branch commands but was rejected as a stray positional on leaves, so the reader had to already know a command's shape to know whether the second spelling applied to it. Add `cli::yt_command()` as the one constructor for the clap command tree. It walks the tree and calls `disable_help_subcommand(true)` at every level, which is required because the setting is per-command and does not propagate from the root. `main.rs` parses through it via `Cli::from_arg_matches` instead of `Cli::parse()`, and `completions.rs` generates through it as well, so no generated completion script offers a spelling the binary rejects. `-h` / `--help` are a separate mechanism and are untouched; `yt help` now fails with clap's unrecognized-subcommand error, which points at `--help` and fails the same way on branches and leaves alike. Three tests cover it: a tree walk asserting every subcommand-bearing command has the setting, a behavior test that `yt help` / `yt config help` / `yt mcp secret help` are rejected rather than printing help, and one pinning `--help` / `-h`. The walk asserts the setting rather than searching for an injected `help` in `get_subcommands()`, because clap injects it lazily during `Command::build()` and an unbuilt tree never shows it. Calling `build()` in the test is not possible today: it runs clap's debug asserts over the whole tree and `yt list` trips one by binding `-q` to both the global `--quiet` and its own `--query`. That is a real pre-existing bug, out of scope here, and is recorded for a follow-up issue. #YT-63
chore(cli): remove clap's auto-generated help subcommand
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 53s
Create release / Create release from merged PR (pull_request) Has been skipped
8e57bbb2fe
`--help` / `-h` is now the one spelling for help. clap injected a `help` subcommand into every command built from a subcommand enum, rendering identical output through the same code path as the flag. The redundancy was conditional and therefore worse than plain redundancy: `help` worked on branch commands but was rejected as a stray positional on leaves, so the reader had to already know a command's shape to know whether the second spelling applied to it.

Add `cli::yt_command()` as the one constructor for the clap command tree. It walks the tree and calls `disable_help_subcommand(true)` at every level, which is required because the setting is per-command and does not propagate from the root. `main.rs` parses through it via `Cli::from_arg_matches` instead of `Cli::parse()`, and `completions.rs` generates through it as well, so no generated completion script offers a spelling the binary rejects. `-h` / `--help` are a separate mechanism and are untouched; `yt help` now fails with clap's unrecognized-subcommand error, which points at `--help` and fails the same way on branches and leaves alike.

Three tests cover it: a tree walk asserting every subcommand-bearing command has the setting, a behavior test that `yt help` / `yt config help` / `yt mcp secret help` are rejected rather than printing help, and one pinning `--help` / `-h`. The walk asserts the setting rather than searching for an injected `help` in `get_subcommands()`, because clap injects it lazily during `Command::build()` and an unbuilt tree never shows it. Calling `build()` in the test is not possible today: it runs clap's debug asserts over the whole tree and `yt list` trips one by binding `-q` to both the global `--quiet` and its own `--query`. That is a real pre-existing bug, out of scope here, and is recorded for a follow-up issue.

#YT-63
Claude-Run deleted branch chore/YT-63-remove-help-subcommand 2026-07-17 12:44:22 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pandoras-box/youtrack-cli!120
No description provided.