Skip to content

Commit d6407ba

Browse files
committed
Added spacing between verbose help tables for better readability.
1 parent 77cfdb8 commit d6407ba

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

cmd2/cmd2.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4079,14 +4079,23 @@ def do_help(self, args: argparse.Namespace) -> None:
40794079
self.poutput(self.doc_leader, style=Cmd2Style.HELP_LEADER)
40804080
self.poutput()
40814081

4082-
if not cmds_cats:
4083-
# No categories found, fall back to standard behavior
4084-
self._print_documented_command_topics(self.doc_header, cmds_doc, args.verbose)
4085-
else:
4086-
# Categories found, Organize all commands by category
4087-
for category in sorted(cmds_cats.keys(), key=self.default_sort_key):
4088-
self._print_documented_command_topics(category, cmds_cats[category], args.verbose)
4089-
self._print_documented_command_topics(self.default_category, cmds_doc, args.verbose)
4082+
# Print any categories first and then the default category.
4083+
sorted_categories = sorted(cmds_cats.keys(), key=self.default_sort_key)
4084+
all_cmds = {category: cmds_cats[category] for category in sorted_categories}
4085+
all_cmds[self.doc_header] = cmds_doc
4086+
4087+
# Used to provide verbose table separation for better readability.
4088+
previous_table_printed = False
4089+
4090+
for category, commands in all_cmds.items():
4091+
if previous_table_printed:
4092+
self.poutput()
4093+
4094+
self._print_documented_command_topics(category, commands, args.verbose)
4095+
previous_table_printed = bool(commands) and args.verbose
4096+
4097+
if previous_table_printed and (help_topics or cmds_undoc):
4098+
self.poutput()
40904099

40914100
self.print_topics(self.misc_header, help_topics, 15, 80)
40924101
self.print_topics(self.undoc_header, cmds_undoc, 15, 80)
@@ -4102,7 +4111,7 @@ def do_help(self, args: argparse.Namespace) -> None:
41024111
completer = argparse_completer.DEFAULT_AP_COMPLETER(argparser, self)
41034112
completer.print_help(args.subcommands, self.stdout)
41044113

4105-
# If there is a help func delegate to do_help
4114+
# If the command has a custom help function, then call it
41064115
elif help_func is not None:
41074116
help_func()
41084117

0 commit comments

Comments
 (0)