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
App
and start the command loop:
Instatiating and starting a cmd2 app | |
---|---|
Getting Started
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
cmd2
and associated optional dependencies - First Application - a sample application showing 8 key features of
cmd2
- Integrate cmd2 Into Your Project - adding
cmd2
to your project - Alternatives - other python packages that might meet your needs
- Resources - related links and other materials
Migrating from cmd
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
cmd2
instead of cmd - Incompatibilities -
cmd2
is 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 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
- Transcripts