File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -337,6 +337,8 @@ class Cmd:
337337 # not been explicitly categorized with the @with_category decorator.
338338 # This value is inherited by subclasses but they can set their own
339339 # DEFAULT_CATEGORY to place their commands into a custom category.
340+ # Subclasses can also reassign cmd2.Cmd.DEFAULT_CATEGORY to rename
341+ # the category used for the framework's built-in commands.
340342 DEFAULT_CATEGORY : ClassVar [str ] = "Cmd2 Commands"
341343
342344 # Header for table listing help topics not related to a command.
Original file line number Diff line number Diff line change @@ -90,7 +90,19 @@ class Plugin(cmd2.CommandSet):
9090
9191When using inheritance, ` cmd2 ` uses the ` DEFAULT_CATEGORY ` of the class where the command was
9292actually defined. This means built-in commands (like ` help ` , ` history ` , and ` quit ` ) stay in the
93- ` "cmd2 Commands" ` category, while your commands move to your custom category.
93+ ` "Cmd2 Commands" ` category, while your commands move to your custom category.
94+
95+ If you want to rename the built-in category itself, you can do so by reassigning
96+ ` cmd2.Cmd.DEFAULT_CATEGORY ` at the class level within your ` Cmd ` subclass:
97+
98+ ``` py
99+ class MyApp (cmd2 .Cmd ):
100+ # Rename the framework's built-in category
101+ cmd2.Cmd.DEFAULT_CATEGORY = ' Shell Commands'
102+
103+ # Set the category for your own commands
104+ DEFAULT_CATEGORY = ' Application Commands'
105+ ```
94106
95107For a complete demonstration of this functionality, see the
96108[ default_categories.py] ( https://github.com/python-cmd2/cmd2/blob/main/examples/default_categories.py )
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ class CategoryApp(cmd2.Cmd):
3636 # This sets the default category for all commands defined in this class
3737 DEFAULT_CATEGORY = "Application Commands"
3838
39+ # This overrides the category for the cmd2 built-in commands
40+ cmd2 .Cmd .DEFAULT_CATEGORY = "Cmd2 Shell Commands"
41+
3942 def __init__ (self ) -> None :
4043 super ().__init__ ()
4144 # Register a command set to show how its categories integrate
You can’t perform that action at this time.
0 commit comments