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/examples | |
parent | 9fd5f6274da443db4f37273d1284e6d09f94aab5 (diff) | |
download | cmd2-git-b9d21a222f02735be3c36be0cab8e83770619373.tar.gz |
Document hiding and disabling commands
For #765
Diffstat (limited to 'docs/examples')
-rw-r--r-- | docs/examples/index.rst | 1 | ||||
-rw-r--r-- | docs/examples/remove_builtin_commands.rst | 41 |
2 files changed, 0 insertions, 42 deletions
diff --git a/docs/examples/index.rst b/docs/examples/index.rst index f895059f..94a3e06f 100644 --- a/docs/examples/index.rst +++ b/docs/examples/index.rst @@ -5,5 +5,4 @@ Examples :maxdepth: 1 first_app - remove_builtin_commands alternate_event_loops diff --git a/docs/examples/remove_builtin_commands.rst b/docs/examples/remove_builtin_commands.rst deleted file mode 100644 index c3e73b0c..00000000 --- a/docs/examples/remove_builtin_commands.rst +++ /dev/null @@ -1,41 +0,0 @@ -Remove Built-in Commands -========================= - -``cmd2`` comes with a bunch of built-in commands. These commands add lots of -useful functionality, but you might not want them in your application. You can -either hide these commands, or remove them completely. - - -Hiding Commands ---------------- - -When a command is hidden, it is still available to run, but it won't show in -the help menu. To hide a command:: - - class HideBuiltinCommand(cmd2.Cmd): - """Hide a built-in command.""" - - def __init__(self): - super().__init__() - - # To prevent commands from displaying in the help menu - # add them to the hidden_commands list - self.hidden_commands.append('py') - - -Removing Commands ------------------ - -You can remove a command from your application is defined in ``cmd2.Cmd`` or -inherited from a :ref:`plugin <features/plugins:Plugins>`. Delete the -command method in your initialization code:: - - class RemoveBuiltinCommand(cmd2.Cmd): - """Remove an undesired built-in command.""" - - def __init__(self): - super().__init__() - - # To remove built-in commands entirely, delete - # the "do_*" function from the cmd2.Cmd class - del cmd2.Cmd.do_edit |