diff options
author | kotfu <kotfu@kotfu.net> | 2020-02-15 19:03:47 -0700 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2020-02-15 19:03:47 -0700 |
commit | 1e57b0c451de23338378f44088118648848cc82c (patch) | |
tree | 37f2d17230cd79b4e9203bf1f83315f932e6b58d /docs/api | |
parent | 3448438f27c5b040e3e4c742a880cf660695e563 (diff) | |
download | cmd2-git-1e57b0c451de23338378f44088118648848cc82c.tar.gz |
Add API documentation for constants
Diffstat (limited to 'docs/api')
-rw-r--r-- | docs/api/constants.rst | 29 | ||||
-rw-r--r-- | docs/api/index.rst | 1 |
2 files changed, 30 insertions, 0 deletions
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 |