diff options
author | kotfu <kotfu@kotfu.net> | 2019-08-25 20:52:33 -0600 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2019-08-25 20:52:33 -0600 |
commit | b9d21a222f02735be3c36be0cab8e83770619373 (patch) | |
tree | 7301d49791606efdda54e8f7c501f21f75f53a84 /docs/features/commands.rst | |
parent | 9fd5f6274da443db4f37273d1284e6d09f94aab5 (diff) | |
download | cmd2-git-b9d21a222f02735be3c36be0cab8e83770619373.tar.gz |
Document hiding and disabling commands
For #765
Diffstat (limited to 'docs/features/commands.rst')
-rw-r--r-- | docs/features/commands.rst | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/docs/features/commands.rst b/docs/features/commands.rst index ab53e990..196944b5 100644 --- a/docs/features/commands.rst +++ b/docs/features/commands.rst @@ -140,8 +140,12 @@ Exit Codes ``cmd2`` has basic infrastructure to support sh/ksh/csh/bash type exit codes. The ``cmd2.Cmd`` object sets an ``exit_code`` attribute to zero when it is instantiated. The value of this attribute is returned from the ``cmdloop()`` -call, so if you want to get an exit code back to the operating system shell, -you can do so like this:: +call. Therefore, if you don't do anything with this attribute in your code, +``cmdloop()`` will (almost) always return zero. There are a few built-in +``cmd2`` commands which set ``exit_code`` to ``-1`` if an error occers. + +You can use this capability to easily return your own values to the operating +system shell:: #!/usr/bin/env python """A simple cmd2 application.""" @@ -183,9 +187,12 @@ name and message. If `debug` is `true`, ``cmd2`` will display a traceback, and then display the exception name and message. -Remove Built-in Commands ------------------------- +Disabling or Hiding Commands +---------------------------- + +See :ref:`features/disable_commands:Disabling Commands` for details of how +to: -See the :ref:`examples/remove_builtin_commands:Remove Built-in Commands` -example for information on hiding or removing commands included in ``cmd2`` -which you might not want in your application. +- removing commands included in ``cmd2`` +- hiding commands from the help menu +- disabling and re-enabling commands at runtime |