summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd2/constants.py10
-rw-r--r--docs/api/constants.rst29
-rw-r--r--docs/api/index.rst1
3 files changed, 37 insertions, 3 deletions
diff --git a/cmd2/constants.py b/cmd2/constants.py
index bc72817f..d7e52cc9 100644
--- a/cmd2/constants.py
+++ b/cmd2/constants.py
@@ -1,6 +1,10 @@
#
# coding=utf-8
-"""Constants and definitions"""
+"""This module contains constants used throughout ``cmd2``."""
+
+# Unless documented in https://cmd2.readthedocs.io/en/latest/api/index.html
+# nothing here should be considered part of the public API of this module
+
# Used for command parsing, output redirection, tab completion and word
# breaks. Do not change.
@@ -32,9 +36,9 @@ HELP_FUNC_PREFIX = 'help_'
# All command completer functions start with this
COMPLETER_FUNC_PREFIX = 'complete_'
-############################################################################################################
+##############################################################################
# The following are optional attributes added to do_* command functions
-############################################################################################################
+##############################################################################
# The custom help category a command belongs to
CMD_ATTR_HELP_CATEGORY = 'help_category'
diff --git a/docs/api/constants.rst b/docs/api/constants.rst
new file mode 100644
index 00000000..b48ba462
--- /dev/null
+++ b/docs/api/constants.rst
@@ -0,0 +1,29 @@
+cmd2.constants
+==============
+
+.. automodule:: cmd2.constants
+
+ .. data:: DEFAULT_SHORTCUTS
+
+ If you do not supply shortcuts to :meth:`cmd2.Cmd.__init__`, the shortcuts
+ defined here will be used instead.
+
+
+ .. data:: COMMAND_NAME
+
+ Used by :meth:`cmd2.Cmd.disable_command` and
+ :meth:`cmd2.Cmd.disable_category`. Those methods allow you to selectively
+ disable single commands or an entire category of commands. Should you want
+ to include the name of the command in the error message displayed to the
+ user when they try and run a disabled command, you can include this
+ constant in the message where you would like the name of the command to
+ appear. ``cmd2`` will replace this constant with the name of the command
+ the user tried to run before displaying the error message.
+
+ This constant is imported into the package namespace; the preferred syntax
+ to import and reference it is::
+
+ import cmd2
+ errmsg = "The {} command is currently disabled.".format(cmd2.COMMAND_NAME)
+
+ See ``src/examples/help_categories.py`` for an example.
diff --git a/docs/api/index.rst b/docs/api/index.rst
index a0ee388c..864b8290 100644
--- a/docs/api/index.rst
+++ b/docs/api/index.rst
@@ -10,3 +10,4 @@ API Reference
exceptions
ansi
utils
+ constants