@@ -2,13 +2,17 @@ Builtin Commands
22================
33
44Applications which subclass :class: `cmd2.cmd2.Cmd ` inherit a number of commands
5- which may be useful to your users.
5+ which may be useful to your users. Developers can
6+ :ref: `features/builtin_commands:Remove Builtin Commands ` if they do not want
7+ them to be part of the application.
68
79edit
810----
911
1012This command launches an editor program and instructs it to open the given file
11- name. Here's an example::
13+ name. Here's an example:
14+
15+ .. code-block :: text
1216
1317 (Cmd) edit ~/.ssh/config
1418
2024---
2125
2226A list of all user-settable parameters, with brief comments, is viewable from
23- within a running application::
27+ within a running application:
28+
29+ .. code-block :: text
2430
2531 (Cmd) set --long
2632 allow_style: Terminal # Allow ANSI escape sequences in output (valid values: Terminal, Always, Never)
@@ -36,13 +42,34 @@ within a running application::
3642 timing: False # Report execution times
3743
3844 Any of these user-settable parameters can be set while running your app with
39- the ``set `` command like so::
45+ the ``set `` command like so:
46+
47+ .. code-block :: text
4048
4149 (Cmd) set allow_style Never
4250
4351
44- Removing A Builtin Command
45- --------------------------
52+ shell
53+ -----
54+
55+ Execute a command as if at the operating system shell prompt:
56+
57+ .. code-block :: text
58+
59+ (Cmd) shell pwd -P
60+ /usr/local/bin
61+
62+
63+ Remove Builtin Commands
64+ -----------------------
65+
66+ Developers may not want to offer the commands builtin to :class: `cmd2.cmd2.Cmd `
67+ to users of their application. To remove a command you must delete the method
68+ implementing that command from the :class: `cmd2.cmd2.Cmd ` object at runtime.
69+ For example, if you wanted to remove the :ref: `features/builtin_commands:shell `
70+ command from your application::
71+
72+ class NoShellApp(cmd2.Cmd):
73+ """A simple cmd2 application."""
4674
47- [TODO] show how to remove a builtin command if you don't want it available to
48- your users.
75+ delattr(cmd2.Cmd, 'do_shell')
0 commit comments