chore(cli): remove clap's auto-generated help subcommand #120
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/YT-63-remove-help-subcommand"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
--help/-his now the one spelling for help. clap injected ahelpsubcommand 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:helpworked 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 callsdisable_help_subcommand(true)at every level, which is required because the setting is per-command and does not propagate from the root.main.rsparses through it viaCli::from_arg_matchesinstead ofCli::parse(), andcompletions.rsgenerates through it as well, so no generated completion script offers a spelling the binary rejects.-h/--helpare a separate mechanism and are untouched;yt helpnow fails with clap's unrecognized-subcommand error, which points at--helpand 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 helpare rejected rather than printing help, and one pinning--help/-h. The walk asserts the setting rather than searching for an injectedhelpinget_subcommands(), because clap injects it lazily duringCommand::build()and an unbuilt tree never shows it. Callingbuild()in the test is not possible today: it runs clap's debug asserts over the whole tree andyt listtrips one by binding-qto both the global--quietand its own--query. That is a real pre-existing bug, out of scope here, and is recorded for a follow-up issue.#YT-63
helpsubcommand