Skip to content

Commit 6e54661

Browse files
committed
Don't recognize help functions for argparse commands
1 parent 9299494 commit 6e54661

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cmd2/cmd2.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,9 +2687,11 @@ def _print_topics(self, header: str, cmds: List[str], verbose: bool) -> None:
26872687
topics = self.get_help_topics()
26882688

26892689
for command in cmds:
2690-
# First see if there's a help function implemented
2691-
if command in topics:
2692-
func = getattr(self, HELP_FUNC_PREFIX + command)
2690+
cmd_func = self.cmd_func(command)
2691+
2692+
# Non-argparse commands can have help_functions for their documentation
2693+
if not hasattr(cmd_func, 'argparser') and command in topics:
2694+
help_func = getattr(self, HELP_FUNC_PREFIX + command)
26932695
result = io.StringIO()
26942696

26952697
# try to redirect system stdout
@@ -2699,16 +2701,14 @@ def _print_topics(self, header: str, cmds: List[str], verbose: bool) -> None:
26992701
try:
27002702
# redirect our internal stdout
27012703
self.stdout = result
2702-
func()
2704+
help_func()
27032705
finally:
27042706
# restore internal stdout
27052707
self.stdout = stdout_orig
27062708
doc = result.getvalue()
27072709

27082710
else:
2709-
# Couldn't find a help function
2710-
func = self.cmd_func(command)
2711-
doc = func.__doc__
2711+
doc = cmd_func.__doc__
27122712

27132713
# Attempt to locate the first documentation block
27142714
doc_block = []

0 commit comments

Comments
 (0)