1
0

CLI: show the list of commands if run_electrum -h is invoked

This fixes a regression likely introduced with the docstring parameter parser.
The short description is the first period-separated sentence of the docstring.

Also remove the 'commands' command.
This commit is contained in:
ThomasV
2025-05-28 15:25:26 +02:00
parent fb9e300165
commit c61e0f5cf9

View File

@@ -130,6 +130,7 @@ class Command:
def parse_docstring(self, docstring):
docstring = docstring or ''
docstring = docstring.strip()
self.description = docstring
self.arg_descriptions = {}
self.arg_types = {}
@@ -137,6 +138,7 @@ class Command:
self.arg_descriptions[x.group(2)] = x.group(3)
self.arg_types[x.group(2)] = x.group(1)
self.description = self.description.replace(x.group(), '')
self.short_description = self.description.split('.')[0]
def command(s):
@@ -230,11 +232,6 @@ class Commands(Logger):
self._callback()
return result
@command('')
async def commands(self):
"""List of commands"""
return ' '.join(sorted(known_commands.keys()))
@command('n')
async def getinfo(self):
""" network info """
@@ -1595,11 +1592,13 @@ class Commands(Logger):
@command('wl')
async def nodeid(self, wallet: Abstract_Wallet = None):
"""Return the Lightning Node ID of a wallet"""
listen_addr = self.config.LIGHTNING_LISTEN
return wallet.lnworker.node_keypair.pubkey.hex() + (('@' + listen_addr) if listen_addr else '')
@command('wl')
async def list_channels(self, wallet: Abstract_Wallet = None):
"""Return the list of Lightning channels in a wallet"""
# FIXME: we need to be online to display capacity of backups
from .lnutil import LOCAL, REMOTE, format_short_channel_id
channels = list(wallet.lnworker.channels.items())
@@ -2182,7 +2181,9 @@ def get_parser():
for cmdname in sorted(known_commands.keys()):
cmd = known_commands[cmdname]
p = subparsers.add_parser(
cmdname, description=cmd.description,
cmdname,
description=cmd.description,
help=cmd.short_description,
epilog="Run 'electrum -h to see the list of global options",
)
for optname, default in zip(cmd.options, cmd.defaults):