cmd2
Cmd2 is an open-source Python library for building interactive command-line interfaces. It extends Python's standard library cmd module to provide a framework for creating line-oriented shells and administrative consoles. Cmd2 emphasizes ease of use, extensibility, and interactive features suitable for tools that require structured user input.
- Subclassing of the cmd2.Cmd base class to define custom shells
- Command handling via methods named do_<command> on the subclass
- Built-in help support and auto-generated command documentation
- Command-line editing and history, with support for tab completion
- Argparse-style argument parsing through an integrated Cmd2ArgumentParser
- Colorized output and improved readability of prompts and messages
- Session logging, scripting, and playback of command sessions
- A plugin system for extending functionality without modifying core code
- Dynamic command discovery and easy customization of prompts and intro text
Usage generally involves creating a subclass of cmd2.Cmd and implementing do_<command> methods to process user input.
Cmd2 is maintained by an open-source community and is available on PyPI for easy installation.