Applications which subclass [cmd2.Cmd][] inherit a number of commands which may be useful to your users. Developers can Remove Builtin Commands if they do not want them to be part of the application.
This command manages aliases via subcommands create, delete, and list. See
Aliases for more information.
This command launches an editor program and instructs it to open the given file name. Here's an example:
(Cmd) edit ~/.ssh/configThe program to be launched is determined by the value of the editor setting.
This command lists available commands or provides detailed help for a specific command. When called
with the -v/--verbose argument, it shows a brief description of each command. See Help
for more information.
This command allows you to view, run, edit, save, or clear previously entered commands from the history. See History for more information.
This optional opt-in command enters an interactive :simple-jupyter: IPython shell. See IPython (optional) for more information.
This command manages macros via subcommands create, delete, and list. A macro is similar to an
alias, but it can contain argument placeholders. See Macros
for more information.
This optional opt-in command invokes a Python command or shell. See Embedded Python Shells for more information.
This command exits the cmd2 application.
This command runs a Python script file inside the cmd2 application. See
Python Scripts for more information.
This command runs commands in a script file that is encoded as either ASCII or UTF-8 text. See Command Scripts for more information.
This command is hidden from the help that's visible to end users. It runs a script like run_script but does so using a path relative to the script that is currently executing. This is useful when you have scripts that run other scripts. See Running Command Scripts for more information.
A list of all user-settable parameters, with brief comments, is viewable from within a running application:
(Cmd) set
Name Value Description
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
allow_style Terminal Allow ANSI text style sequences in output (valid values: Always, Never, Terminal)
debug False Show full traceback on exception
echo False Echo command issued into output
editor vim Program used by 'edit'
feedback_to_output False Include nonessentials in '|' and '>' results
max_column_completion_results 7 Maximum number of completion results to display in a single column
max_completion_table_items 50 Maximum number of completion results allowed for a completion table to appear
quiet False Don't print nonessential feedback
scripts_add_to_history True Scripts and pyscripts add commands to history
timing False Report execution times
traceback_show_locals False Display local variables in tracebacks
Any of these user-settable parameters can be set while running your app with the set command like
so:
(Cmd) set allow_style Never
See Settings for more information.
Execute a command as if at the operating system shell prompt:
(Cmd) shell pwd -P
/usr/local/bin
This command lists available shortcuts. See Shortcuts for more information.
Developers may not want to offer all the commands built into [cmd2.Cmd][] to users of their application. To remove a command you must delete the method implementing that command from the [cmd2.Cmd][] object at runtime. For example, if you wanted to remove the shell command from your application:
class NoShellApp(cmd2.Cmd):
"""A simple cmd2 application."""
delattr(cmd2.Cmd, 'do_shell')