lncli: show subcommands in lncli help <command> - #11157
Conversation
The cli library renders the help of a command with a template that has no section for subcommands. So `lncli help wallet` only printed the name and usage of the wallet command, while `lncli wallet --help` also listed everything below it. Replace the library's help command with one that hands a command that has subcommands to its own help output, so both ways of asking print the same thing. The library only registers the global help flag if the application doesn't declare a help command itself, so that flag is now added by hand. Fixes lightningnetwork#7975. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
🟡 PR Severity: MEDIUM
🟡 Medium (2 files)
🟢 Low (2 files)
AnalysisAll substantive changes are confined to To override, add a |
Change Description
Fixes #7975.
lncli help walletprinted only the name, usage and category of thewalletcommand, while
lncli wallet --helpalso listed everything below it:The cli library's
helpcommand always renders throughcli.ShowCommandHelp,which uses the flat
CommandHelpTemplate. That template has no section forsubcommands. The
--helpflag takes a different path: a command that hassubcommands is turned into its own sub-application, which is rendered with
SubcommandHelpTemplateand does list them.This replaces the library's
helpcommand with one that hands a command thathas subcommands to that same sub-application path, so both ways of asking print
the same thing. Commands without subcommands, and names that don't resolve to a
command at all, keep going through
cli.ShowCommandHelpunchanged.The library only registers the global help flag if the application doesn't
declare a command called
helpitself, socli.HelpFlagis now added toapp.Flagsby hand.lncli --helpandlncli -hare unaffected.After:
Steps to Test
Build
lncliand compare the two ways of asking for help:The output is now identical. The same holds for the other commands that have
subcommands (
profile,wtclient,peers,chain).lncli help sendcoins,lncli help,lncli --helpandlncli help <unknown>(still exit code 3) areunchanged.
Unit tests:
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]in the commit message for small changes.