Description
cmd2 is a Python library for building interactive command-line applications and REPLs. You start from a subclass of the standard library's cmd.Cmd and add commands as Python methods, and cmd2 takes care of argument parsing, generated help, tab completion, command history, scripting and output styling. Arguments can be defined with familiar argparse parsers and subcommands, or with type hints through the @with_annotated decorator in a Typer-like style; one definition drives validation, help and completion. Output can include Rich tables and other styled objects, with helpers for errors, warnings and paging. Large applications can be split into independently testable CommandSets that load dynamically. Built-in features include aliases, macros, shell integration and script running. It suits anything from a small internal tool to a large scriptable interface.…
Highlights
- Extends Python's cmd.Cmd
- argparse or type-hint argument definitions
- Auto help, tab completion and validation
- History, aliases, macros and scripting
- Rich tables and styled output
- Modular CommandSets
Ratings & Reviews
No ratings yet
Be the first to rate Cmd2.
People also visit
Cmd2 FAQ
What is cmd2?
A Python framework for building feature-rich interactive command-line applications and REPLs, based on the standard library's cmd module.
How do I define command arguments?
Use argparse parsers, or annotate a method with @cmd2.with_annotated and use type hints; the same definition powers validation, help and tab completion.
What do I get without extra code?
Generated help, tab completion, command history, aliases, macros, scripting and shell integration.
How do I get started?
Install cmd2 with pip, create an app.py that subclasses cmd2.Cmd, and run it with python app.py. A getting started tutorial covers a fuller application.
What are the best Cmd2 alternatives?
Popular alternatives to Cmd2 include ngxpert/cmdk, Commands Manager and BeeWare. See all Cmd2 alternatives











