@@ -1981,6 +1981,23 @@ def test_get_help_topics(base_app):
1981
1981
custom_help = base_app .get_help_topics ()
1982
1982
assert len (custom_help ) == 0
1983
1983
1984
+ def test_get_help_topics_hidden ():
1985
+ # Verify get_help_topics() filters out hidden commands
1986
+ class TestApp (cmd2 .Cmd ):
1987
+ def __init__ (self , * args , ** kwargs ):
1988
+ super ().__init__ (* args , ** kwargs )
1989
+
1990
+ def do_my_cmd (self , args ):
1991
+ pass
1992
+
1993
+ def help_my_cmd (self , args ):
1994
+ pass
1995
+
1996
+ app = TestApp ()
1997
+ assert 'my_cmd' in app .get_help_topics ()
1998
+
1999
+ app .hidden_commands .append ('my_cmd' )
2000
+ assert 'my_cmd' not in app .get_help_topics ()
1984
2001
1985
2002
class ReplWithExitCode (cmd2 .Cmd ):
1986
2003
""" Example cmd2 application where we can specify an exit code when existing."""
@@ -2240,6 +2257,10 @@ def test_disable_and_enable_category(disable_commands_app):
2240
2257
assert 'has_helper_funcs' not in visible_commands
2241
2258
assert 'has_no_helper_funcs' not in visible_commands
2242
2259
2260
+ # Make sure get_help_topics() filters out disabled commands
2261
+ help_topics = disable_commands_app .get_help_topics ()
2262
+ assert 'has_helper_funcs' not in help_topics
2263
+
2243
2264
##########################################################################
2244
2265
# Enable the category
2245
2266
##########################################################################
@@ -2281,6 +2302,10 @@ def test_disable_and_enable_category(disable_commands_app):
2281
2302
assert 'has_helper_funcs' in visible_commands
2282
2303
assert 'has_no_helper_funcs' in visible_commands
2283
2304
2305
+ # Make sure get_help_topics() contains our help function
2306
+ help_topics = disable_commands_app .get_help_topics ()
2307
+ assert 'has_helper_funcs' in help_topics
2308
+
2284
2309
def test_enable_enabled_command (disable_commands_app ):
2285
2310
# Test enabling a command that is not disabled
2286
2311
saved_len = len (disable_commands_app .disabled_commands )
0 commit comments