cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python
See the codeQuick start • Why cmd2? • Installation • Documentation • Projects using cmd2
cmd2 makes it quick to build powerful, polished command-line applications and REPLs in Python.
Start with a subclass of the standard library's
cmd.Cmd, then add commands while cmd2 handles the
details that make an application pleasant to build and use: argument parsing, generated help, tab
completion, command history, scripting, output styling, and much more.
You can use cmd2 for a small internal tool and grow the same application into an extensible,
scriptable interface without replacing the framework or writing the usual CLI boilerplate.
Install cmd2:
pip install cmd2
Then create app.py:
from typing import Annotated
import cmd2
from cmd2.annotated import Argument, Option
class App(cmd2.Cmd):
"""A small interactive application."""
@cmd2.with_annotated
def do_greet(
self,
name: Annotated[str, Argument(help_text="person to greet")],
count: Annotated[int, Option(help_text="number of greetings")] = 1,
) -> None:
"""Greet a person."""
for _ in range(count):
self.poutput(f"Hello, {name}!")
if __name__ == "__main__":
App().cmdloop()
cmd2 supports Typer-style syntax for specifying command arguments
with type annotations. In this example, @cmd2.with_annotated turns name and count into a
positional argument and an option.
Run it with python app.py. Your new greet command already has input validation, generated help,
and tab completion for its options. The application also includes discoverable help, command
history, aliases, macros, scripting, shell integration, and other built-in commands.
(Cmd) help greet
Usage: greet [-h] [--count COUNT] name
(Cmd) greet --count 2 Ada
Hello, Ada!
Hello, Ada!
See the getting started tutorial to build a more complete application.
argparse parsers for
arguments and subcommands, or plain type hints via
@with_annotated. A single parser
definition drives validation, help, and completion.prompt-toolkit. Learn more
about keyboard shortcuts.shell command or its ! shortcut. Learn more about
OS integration.On all operating systems, the latest stable version of cmd2 can be installed using pip:
pip install -U cmd2
cmd2 works with Python 3.11+ on Windows, macOS, and Linux. It is pure Python code with few 3rd-party dependencies. It works with both conventional CPython and free-threaded variants.
For information on other installation options, see Installation Instructions in the cmd2 documentation.
[!IMPORTANT] Upgrading from an older release? Versions 3.x and 4.x include significant backwards-incompatible changes. Review the changelog and migration guide before upgrading.
Read the latest documentation online or download it in
HTML, PDF, and ePub formats. The
examples directory contains focused,
runnable demonstrations of individual features.
If you think you've found a bug, please first read through the open Issues. If you're confident it's a new bug, go ahead and create a new GitHub issue. Be sure to include as much information as possible so we can reproduce the bug. At a minimum, please state the following:
cmd2 version| Application Name | Description | Organization or Author |
|---|---|---|
| CephFS Shell | The Ceph File System, or CephFS, is a POSIX-compliant file system built on top of Ceph’s distributed object store | ceph |
| garak | LLM vulnerability scanner that checks if an LLM can be made to fail in a way we don't want | NVIDIA |
| Argus | The Ultimate Information Gathering Toolkit | JASON13 |
| medusa | Binary instrumentation framework that that automates processes for the dynamic analysis of Android and iOS Applications | Ch0pin |
| InternalBlue | Bluetooth experimentation framework for Broadcom and Cypress chips | Secure Mobile Networking Lab |
| SCCMHunter | A post-ex tool built to streamline identifying, profiling, and attacking SCCM related assets in an Active Directory domain | Garret Foster |
| Unipacker | Automatic and platform-independent unpacker for Windows binaries based on emulation | unipacker |
| Frankenstein | Broadcom and Cypress firmware emulation for fuzzing and further full-stack debugging | Secure Mobile Networking Lab |
| Poseidon | Leverages software-defined networks (SDNs) to acquire and then feed network traffic to a number of machine learning techniques. | Faucet SDN |
| DFTimewolf | A framework for orchestrating forensic collection, processing and data export | log2timeline |
| LazyOwn | The first RedTeam/APT Framework with an AI-powered C&C, featuring rootkits to conceal campaigns, undetectable malleable implants | Grisuno |
| GAP SDK | SDK for Greenwaves Technologies' GAP8 IoT Application Processor | GreenWaves Technologies |
| REW Sploit | Emulate and Dissect Metasploit Framework (MSF) and other attacks | REW-sploit |
| tomcatmanager | A command line tool and python library for managing a tomcat server | tomcatmanager |
| Falcon Toolkit | Unleash the power of the CrowdStrike Falcon Platform at the CLI | CrowdStrike |
| EXPLIoT | Internet of Things Security Testing and Exploitation framework | expliot_framework |
| Pobshell | A Bash‑like shell for live Python objects: cd, ls, cat, find and CLI piping for object code, str values & more | Peter Dalloz |
| Wtsh | WTSH is a shell built with Python cmd2(v4), which uses third-party plugins to construct a universal shell installed via Pip | wazzge |
Possibly defunct but still good examples
| Application Name | Description | Organization or Author |
|---|---|---|
| Katana | Automatic CTF Challenge Solver | John Hammond |
| SatanSword (in Chinese) | Comprehensive Penetration Framework for Red Teaming | Lucifer1993 |
| Jok3r | Network & Web Pentest Automation Framework | Koutto |
| Counterfit | a CLI that provides a generic automation layer for assessing the security of ML models | Microsoft Azure |
| Overlord | Red Teaming Infrastructure Automation | QSecure Labs |
| Automated Reconnaissance Pipeline | An automated target reconnaissance pipeline | epi052 |
| JSShell | An interactive multi-user web JavaScript (JS) shell | Den1al |
| RedShell | An interactive command prompt for red teaming and pentesting | Verizon |
| FLASHMINGO | Automatic analysis of SWF files based on some heuristics. Extensible via plugins. | Mandiant |
| psiTurk | An open platform for science on Amazon Mechanical Turk | NYU Computation and Cognition Lab |
Note: If you have created an application based on cmd2 that you would like us to mention here,
please get in touch.
Overall
Maintained
Code review
PyPI
Latest release
Releases this year
315 followers · starred Sep 2024
568 followers · starred Aug 2018
1,540 followers · starred Mar 2025
689 followers · starred Nov 2017
cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python
See the codeQuick start • Why cmd2? • Installation • Documentation • Projects using cmd2
cmd2 makes it quick to build powerful, polished command-line applications and REPLs in Python.
Start with a subclass of the standard library's
cmd.Cmd, then add commands while cmd2 handles the
details that make an application pleasant to build and use: argument parsing, generated help, tab
completion, command history, scripting, output styling, and much more.
You can use cmd2 for a small internal tool and grow the same application into an extensible,
scriptable interface without replacing the framework or writing the usual CLI boilerplate.
Install cmd2:
pip install cmd2
Then create app.py:
from typing import Annotated
import cmd2
from cmd2.annotated import Argument, Option
class App(cmd2.Cmd):
"""A small interactive application."""
@cmd2.with_annotated
def do_greet(
self,
name: Annotated[str, Argument(help_text="person to greet")],
count: Annotated[int, Option(help_text="number of greetings")] = 1,
) -> None:
"""Greet a person."""
for _ in range(count):
self.poutput(f"Hello, {name}!")
if __name__ == "__main__":
App().cmdloop()
cmd2 supports Typer-style syntax for specifying command arguments
with type annotations. In this example, @cmd2.with_annotated turns name and count into a
positional argument and an option.
Run it with python app.py. Your new greet command already has input validation, generated help,
and tab completion for its options. The application also includes discoverable help, command
history, aliases, macros, scripting, shell integration, and other built-in commands.
(Cmd) help greet
Usage: greet [-h] [--count COUNT] name
(Cmd) greet --count 2 Ada
Hello, Ada!
Hello, Ada!
See the getting started tutorial to build a more complete application.
argparse parsers for
arguments and subcommands, or plain type hints via
@with_annotated. A single parser
definition drives validation, help, and completion.prompt-toolkit. Learn more
about keyboard shortcuts.shell command or its ! shortcut. Learn more about
OS integration.On all operating systems, the latest stable version of cmd2 can be installed using pip:
pip install -U cmd2
cmd2 works with Python 3.11+ on Windows, macOS, and Linux. It is pure Python code with few 3rd-party dependencies. It works with both conventional CPython and free-threaded variants.
For information on other installation options, see Installation Instructions in the cmd2 documentation.
[!IMPORTANT] Upgrading from an older release? Versions 3.x and 4.x include significant backwards-incompatible changes. Review the changelog and migration guide before upgrading.
Read the latest documentation online or download it in
HTML, PDF, and ePub formats. The
examples directory contains focused,
runnable demonstrations of individual features.
If you think you've found a bug, please first read through the open Issues. If you're confident it's a new bug, go ahead and create a new GitHub issue. Be sure to include as much information as possible so we can reproduce the bug. At a minimum, please state the following:
cmd2 version| Application Name | Description | Organization or Author |
|---|---|---|
| CephFS Shell | The Ceph File System, or CephFS, is a POSIX-compliant file system built on top of Ceph’s distributed object store | ceph |
| garak | LLM vulnerability scanner that checks if an LLM can be made to fail in a way we don't want | NVIDIA |
| Argus | The Ultimate Information Gathering Toolkit | JASON13 |
| medusa | Binary instrumentation framework that that automates processes for the dynamic analysis of Android and iOS Applications | Ch0pin |
| InternalBlue | Bluetooth experimentation framework for Broadcom and Cypress chips | Secure Mobile Networking Lab |
| SCCMHunter | A post-ex tool built to streamline identifying, profiling, and attacking SCCM related assets in an Active Directory domain | Garret Foster |
| Unipacker | Automatic and platform-independent unpacker for Windows binaries based on emulation | unipacker |
| Frankenstein | Broadcom and Cypress firmware emulation for fuzzing and further full-stack debugging | Secure Mobile Networking Lab |
| Poseidon | Leverages software-defined networks (SDNs) to acquire and then feed network traffic to a number of machine learning techniques. | Faucet SDN |
| DFTimewolf | A framework for orchestrating forensic collection, processing and data export | log2timeline |
| LazyOwn | The first RedTeam/APT Framework with an AI-powered C&C, featuring rootkits to conceal campaigns, undetectable malleable implants | Grisuno |
| GAP SDK | SDK for Greenwaves Technologies' GAP8 IoT Application Processor | GreenWaves Technologies |
| REW Sploit | Emulate and Dissect Metasploit Framework (MSF) and other attacks | REW-sploit |
| tomcatmanager | A command line tool and python library for managing a tomcat server | tomcatmanager |
| Falcon Toolkit | Unleash the power of the CrowdStrike Falcon Platform at the CLI | CrowdStrike |
| EXPLIoT | Internet of Things Security Testing and Exploitation framework | expliot_framework |
| Pobshell | A Bash‑like shell for live Python objects: cd, ls, cat, find and CLI piping for object code, str values & more | Peter Dalloz |
| Wtsh | WTSH is a shell built with Python cmd2(v4), which uses third-party plugins to construct a universal shell installed via Pip | wazzge |
Possibly defunct but still good examples
| Application Name | Description | Organization or Author |
|---|---|---|
| Katana | Automatic CTF Challenge Solver | John Hammond |
| SatanSword (in Chinese) | Comprehensive Penetration Framework for Red Teaming | Lucifer1993 |
| Jok3r | Network & Web Pentest Automation Framework | Koutto |
| Counterfit | a CLI that provides a generic automation layer for assessing the security of ML models | Microsoft Azure |
| Overlord | Red Teaming Infrastructure Automation | QSecure Labs |
| Automated Reconnaissance Pipeline | An automated target reconnaissance pipeline | epi052 |
| JSShell | An interactive multi-user web JavaScript (JS) shell | Den1al |
| RedShell | An interactive command prompt for red teaming and pentesting | Verizon |
| FLASHMINGO | Automatic analysis of SWF files based on some heuristics. Extensible via plugins. | Mandiant |
| psiTurk | An open platform for science on Amazon Mechanical Turk | NYU Computation and Cognition Lab |
Note: If you have created an application based on cmd2 that you would like us to mention here,
please get in touch.
Overall
Maintained
Code review
PyPI
Latest release
Releases this year
315 followers · starred Sep 2024
568 followers · starred Aug 2018
1,540 followers · starred Mar 2025
689 followers · starred Nov 2017