Skip to content

Commit c61e0f5

Browse files
committed
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.
1 parent fb9e300 commit c61e0f5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

electrum/commands.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,15 @@ def __init__(self, func, name, s):
130130

131131
def parse_docstring(self, docstring):
132132
docstring = docstring or ''
133+
docstring = docstring.strip()
133134
self.description = docstring
134135
self.arg_descriptions = {}
135136
self.arg_types = {}
136137
for x in re.finditer(r'arg:(.*?):(.*?):(.*)$', docstring, flags=re.MULTILINE):
137138
self.arg_descriptions[x.group(2)] = x.group(3)
138139
self.arg_types[x.group(2)] = x.group(1)
139140
self.description = self.description.replace(x.group(), '')
141+
self.short_description = self.description.split('.')[0]
140142

141143

142144
def command(s):
@@ -230,11 +232,6 @@ def _run(self, method, args, password_getter=None, **kwargs):
230232
self._callback()
231233
return result
232234

233-
@command('')
234-
async def commands(self):
235-
"""List of commands"""
236-
return ' '.join(sorted(known_commands.keys()))
237-
238235
@command('n')
239236
async def getinfo(self):
240237
""" network info """
@@ -1595,11 +1592,13 @@ async def lnpay(self, invoice, timeout=120, password=None, wallet: Abstract_Wall
15951592

15961593
@command('wl')
15971594
async def nodeid(self, wallet: Abstract_Wallet = None):
1595+
"""Return the Lightning Node ID of a wallet"""
15981596
listen_addr = self.config.LIGHTNING_LISTEN
15991597
return wallet.lnworker.node_keypair.pubkey.hex() + (('@' + listen_addr) if listen_addr else '')
16001598

16011599
@command('wl')
16021600
async def list_channels(self, wallet: Abstract_Wallet = None):
1601+
"""Return the list of Lightning channels in a wallet"""
16031602
# FIXME: we need to be online to display capacity of backups
16041603
from .lnutil import LOCAL, REMOTE, format_short_channel_id
16051604
channels = list(wallet.lnworker.channels.items())
@@ -2182,7 +2181,9 @@ def get_parser():
21822181
for cmdname in sorted(known_commands.keys()):
21832182
cmd = known_commands[cmdname]
21842183
p = subparsers.add_parser(
2185-
cmdname, description=cmd.description,
2184+
cmdname,
2185+
description=cmd.description,
2186+
help=cmd.short_description,
21862187
epilog="Run 'electrum -h to see the list of global options",
21872188
)
21882189
for optname, default in zip(cmd.options, cmd.defaults):

0 commit comments

Comments
 (0)