44A sample application for tagging categories on commands.
55"""
66
7- from cmd2 import Cmd , HELP_CATEGORY , __version__
7+ from cmd2 import Cmd , categorize , __version__
88
99
1010class HelpCategories (Cmd ):
@@ -28,8 +28,8 @@ def do_which(self, _):
2828 self .poutput ('Which' )
2929
3030 # Tag the above command functions under the category Connecting
31- setattr (do_connect , HELP_CATEGORY , CMD_CAT_CONNECTING )
32- setattr (do_which , HELP_CATEGORY , CMD_CAT_CONNECTING )
31+ categorize (do_connect , CMD_CAT_CONNECTING )
32+ categorize (do_which , CMD_CAT_CONNECTING )
3333
3434 def do_list (self , _ ):
3535 """List command"""
@@ -72,16 +72,16 @@ def do_findleakers(self, _):
7272 self .poutput ('Find Leakers' )
7373
7474 # Tag the above command functions under the category Application Management
75- setattr ( do_list , HELP_CATEGORY , CMD_CAT_APP_MGMT )
76- setattr ( do_deploy , HELP_CATEGORY , CMD_CAT_APP_MGMT )
77- setattr ( do_start , HELP_CATEGORY , CMD_CAT_APP_MGMT )
78- setattr ( do_sessions , HELP_CATEGORY , CMD_CAT_APP_MGMT )
79- setattr ( do_redeploy , HELP_CATEGORY , CMD_CAT_APP_MGMT )
80- setattr ( do_restart , HELP_CATEGORY , CMD_CAT_APP_MGMT )
81- setattr ( do_expire , HELP_CATEGORY , CMD_CAT_APP_MGMT )
82- setattr ( do_undeploy , HELP_CATEGORY , CMD_CAT_APP_MGMT )
83- setattr ( do_stop , HELP_CATEGORY , CMD_CAT_APP_MGMT )
84- setattr ( do_findleakers , HELP_CATEGORY , CMD_CAT_APP_MGMT )
75+ categorize (( do_list ,
76+ do_deploy ,
77+ do_start ,
78+ do_sessions ,
79+ do_redeploy ,
80+ do_restart ,
81+ do_expire ,
82+ do_undeploy ,
83+ do_stop ,
84+ do_findleakers ) , CMD_CAT_APP_MGMT )
8585
8686 def do_resources (self , _ ):
8787 """Resources command"""
@@ -108,12 +108,12 @@ def do_vminfo(self, _):
108108 self .poutput ('VM Info' )
109109
110110 # Tag the above command functions under the category Server Information
111- setattr (do_resources , HELP_CATEGORY , CMD_CAT_SERVER_INFO )
112- setattr (do_status , HELP_CATEGORY , CMD_CAT_SERVER_INFO )
113- setattr (do_serverinfo , HELP_CATEGORY , CMD_CAT_SERVER_INFO )
114- setattr (do_thread_dump , HELP_CATEGORY , CMD_CAT_SERVER_INFO )
115- setattr (do_sslconnectorciphers , HELP_CATEGORY , CMD_CAT_SERVER_INFO )
116- setattr (do_vminfo , HELP_CATEGORY , CMD_CAT_SERVER_INFO )
111+ categorize (do_resources , CMD_CAT_SERVER_INFO )
112+ categorize (do_status , CMD_CAT_SERVER_INFO )
113+ categorize (do_serverinfo , CMD_CAT_SERVER_INFO )
114+ categorize (do_thread_dump , CMD_CAT_SERVER_INFO )
115+ categorize (do_sslconnectorciphers , CMD_CAT_SERVER_INFO )
116+ categorize (do_vminfo , CMD_CAT_SERVER_INFO )
117117
118118 # The following command functions don't have the HELP_CATEGORY attribute set
119119 # and show up in the 'Other' group
0 commit comments