Skip to content

Commit 42ea15e

Browse files
committed
Updated documentation
1 parent 3747fb8 commit 42ea15e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cmd2/cmd2.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,6 +3665,10 @@ def disable_command(self, command: str, message_to_print: str) -> None:
36653665
Disable a command and overwrite its functions
36663666
:param command: the command being disabled
36673667
:param message_to_print: what to print when this command is run or help is called on it while disabled
3668+
3669+
The variable COMMAND_NAME can be used as a placeholder for the name of the
3670+
command being disabled.
3671+
ex: message_to_print = "{} is currently disabled".format(COMMAND_NAME)
36683672
"""
36693673
import functools
36703674

@@ -3695,6 +3699,10 @@ def disable_category(self, category: str, message_to_print: str) -> None:
36953699
:param category: the category to disable
36963700
:param message_to_print: what to print when anything in this category is run or help is called on it
36973701
while disabled
3702+
3703+
The variable COMMAND_NAME can be used as a placeholder for the name of the
3704+
command being disabled.
3705+
ex: message_to_print = "{} is currently disabled".format(COMMAND_NAME)
36983706
"""
36993707
all_commands = self.get_all_commands()
37003708

examples/help_categories.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import argparse
88

99
import cmd2
10+
from cmd2.cmd2 import COMMAND_NAME
1011

1112

1213
class HelpCategories(cmd2.Cmd):
@@ -143,7 +144,9 @@ def do_version(self, _):
143144
@cmd2.with_category("Command Management")
144145
def do_disable_commands(self, _):
145146
"""Disable the Application Management commands"""
146-
self.disable_category(self.CMD_CAT_APP_MGMT, "Application Management is currently disabled")
147+
message_to_print = "{} is not available while {} commands are disabled".format(COMMAND_NAME,
148+
self.CMD_CAT_APP_MGMT)
149+
self.disable_category(self.CMD_CAT_APP_MGMT, message_to_print)
147150
self.poutput("The Application Management commands have been disabled")
148151

149152
@cmd2.with_category("Command Management")

0 commit comments

Comments
 (0)