Skip to content

lncli: show subcommands in lncli help <command> - #11157

Open
manantlerio wants to merge 2 commits into
lightningnetwork:masterfrom
manantlerio:fix-help-subcommands
Open

lncli: show subcommands in lncli help <command>#11157
manantlerio wants to merge 2 commits into
lightningnetwork:masterfrom
manantlerio:fix-help-subcommands

Conversation

@manantlerio

Copy link
Copy Markdown

Change Description

Fixes #7975.

lncli help wallet printed only the name, usage and category of the wallet
command, while lncli wallet --help also listed everything below it:

NAME:
   lncli wallet - Interact with the wallet.

USAGE:
   lncli wallet [arguments...]

CATEGORY:
   Wallet

The cli library's help command always renders through cli.ShowCommandHelp,
which uses the flat CommandHelpTemplate. That template has no section for
subcommands. The --help flag takes a different path: a command that has
subcommands is turned into its own sub-application, which is rendered with
SubcommandHelpTemplate and does list them.

This replaces the library's help command with one that hands a command that
has 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.ShowCommandHelp unchanged.

The library only registers the global help flag if the application doesn't
declare a command called help itself, so cli.HelpFlag is now added to
app.Flags by hand. lncli --help and lncli -h are unaffected.

After:

NAME:
   lncli wallet - Interact with the wallet.

USAGE:
   lncli wallet command [command options] [arguments...]

COMMANDS:
   estimatefeerate    Estimates the on-chain fee rate to achieve a confirmation target.
   pendingsweeps      List all outputs that are pending to be swept within lnd.
   bumpfee            Bumps the fee of an arbitrary input/transaction.
   ...
   addresses          Interact with wallet addresses.

OPTIONS:
   --help, -h  show help

Steps to Test

Build lncli and compare the two ways of asking for help:

lncli help wallet
lncli wallet --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 --help and lncli help <unknown> (still exit code 3) are
unchanged.

Unit tests:

go test ./cmd/commands/ -run TestHelp -v

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

manantlerio and others added 2 commits September 1, 2026 14:19
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>
@github-actions github-actions Bot added the severity-medium Focused review required label Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🟡 PR Severity: MEDIUM

file classification | 4 files | 180 lines changed

🟡 Medium (2 files)
  • cmd/commands/cmd_help.go - new file under cmd/commands/*, CLI client help-rendering logic
  • cmd/commands/main.go - CLI app wiring (registers help flag/command)
🟢 Low (2 files)
  • cmd/commands/cmd_help_test.go - test-only file
  • docs/release-notes/release-notes-0.22.0.md - release notes

Analysis

All substantive changes are confined to cmd/commands/*, which is CLI (lncli) client code and is classified MEDIUM regardless of the fact that the affected commands (e.g. wallet, peers, chain) share names with server-side critical packages — per the classification rules, cmd/* does not inherit severity from similarly-named server packages. The change only alters how lncli help <command> renders output (delegating to the library's existing subcommand help path) and does not touch any RPC, wallet, or wire-protocol logic. File count (2 non-test/non-doc files) and line count (180 total, well under the 500-line/20-file bump thresholds) do not warrant a severity bump.


To override, add a severity-override-{critical,high,medium,low} label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

severity-medium Focused review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: lncli help wallet should pull up the wallet man page

1 participant