cmd2
A Python package for building powerful command-line interpreter (CLI) programs. Extends the Python Standard Library's cmd package.
The basic use of cmd2 is identical to that of cmd.
- Create a subclass of cmd2.Cmd. Define attributes and
do_*methods to control its behavior. Throughout this documentation, we will assume that you are naming your subclassApp:
| Creating a class inherited from cmd2.Cmd | |
|---|---|
- Instantiate
Appand start the command loop:
| Instantiating and starting a cmd2 app | |
|---|---|
Getting Started
Building a new REPL or Command Line Interface application?
Already built an application that uses cmd from the python standard library and want to add more functionality with very little work?
cmd2 is a powerful Python library for building command line applications. Start here to find out
if this library is a good fit for your needs.
- Installation Instructions - how to install
cmd2and associated optional dependencies - Getting Started Application - a sample application showing many
key features of
cmd2 - Integrate cmd2 Into Your Project - adding
cmd2to your project - Alternatives - other Python packages that might meet your needs
- Resources - related links and other materials
Migrating From cmd
If you're thinking of migrating your cmd app to
cmd2, this section will help you decide if it's right for your app, and show you how to do it.
- Why cmd2 - we try and convince you to use
cmd2instead of cmd - Incompatibilities -
cmd2is not quite 100% compatible with cmd. - Minimum Required Changes - the minimum changes required to move from
cmd to
cmd2. Start your migration here. - Next Steps - Once you've migrated, here is a list of things you can do next to add even more functionality to your app.
Features
- Argument Processing
- Builtin Commands
- Clipboard Integration
- Commands
- Completion
- Disabling Commands
- Embedded Python Shells
- Generating Output
- Help
- History
- Hooks
- Initialization
- Miscellaneous Features
- Modular Commands
- Multiline Commands
- Integrating with the OS
- Packaging a cmd2 application for distribution
- Plugins
- Prompt
- Output Redirection and Pipes
- Scripting
- Settings
- Shortcuts, Aliases, and Macros
- Startup Commands
- Table Creation
- Theme
- Transcripts