From cdeb15aa95f87fb70d26a20bba3f1856aafff1f2 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 29 Sep 2026 09:23:30 +0000 Subject: [PATCH] tool.help: `gen_tool_usage()` -> `gen_usage_body()` --- mmgen/tool/help.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mmgen/tool/help.py b/mmgen/tool/help.py index c6b30e55..97a19986 100755 --- a/mmgen/tool/help.py +++ b/mmgen/tool/help.py @@ -20,6 +20,7 @@ tool.help: Help screen routines for the 'mmgen-tool' utility """ +from ..util import capfirst from .. import main_tool from .common import tool_cmd_base, fstr @@ -102,15 +103,10 @@ def main_help(): return '\n'.join(do()) -def gen_tool_usage(): +def gen_usage_body(mods_data, get_mod_cls_func): - from ..util import capfirst - - for line in usage_hdr.lstrip().split('\n'): - yield line - - for clsname, cmdlist in main_tool.mods.items(): - cls = main_tool.get_mod_cls(clsname) + for clsname, cmdlist in mods_data.items(): + cls = get_mod_cls_func(clsname) cls_docstr = cls.__doc__.strip() yield '' yield ' {}:'.format(capfirst(cls_docstr.split('\n')[0].strip())) @@ -129,9 +125,6 @@ def gen_tool_usage(): w = max_w) yield '' - for line in usage_examples.rstrip().split('\n'): - yield line - def gen_tool_cmd_usage(mod, cmdname): from ..cfg import gc @@ -185,6 +178,7 @@ def gen_tool_cmd_usage(mod, cmdname): def usage(cmdname, *, exit_val=1): + from ..main_tool import mods, get_mod_cls from ..util import Msg, die if cmdname: @@ -196,7 +190,10 @@ def usage(cmdname, *, exit_val=1): die(1, f'{cmdname!r}: no such tool command') else: from ..ui import do_pager - do_pager('\n'.join(gen_tool_usage()) + '\n') + do_pager( + usage_hdr.lstrip() + + '\n' + '\n'.join(gen_usage_body(mods, get_mod_cls)) + + '\n' + usage_examples.rstrip()) import sys sys.exit(exit_val)