A Hands-On Guide to Building Interactive Command-Line Apps with cmd2
summary
cmd2 is a drop-in extension of Python’s cmd module that demos a working, feature-rich interactive shell: GitHub-hosted with CI on Windows/Mac/Linux, >97% code coverage and ~28 contributors. It shows live examples of built-in help, top-notch tab completion (including dynamic choices and negative-number handling), shell execution with piping/redirect, persistent history, aliases/macros, argparse decorators for automatic completions, embedded IPython and Python scripting, an async alert API, a regression-test framework, and broad Python 3.5+ compatibility.
AI-written summary · about
chapters (25)
- 0:00Intro
- 1:22Overview
- 2:46Why build a CLI?
- 3:47Why use cmd2 to build your CLI?
- 4:21cmd2 Main Features
- 4:38Create a cmd2 application
- 6:07Add a cmd2 command
- 9:15Add help for a cmd2 command
- 9:40Tab completion for a cmd2 command
- 10:09Searchable command history
- 11:55Built-in editor
- 12:27Settable environment parameters
- 14:02Shell commands
- 14:57Output redirection or pipe
- 16:40Commands at invocation
- 17:56Text File Scripts
- 21:49Macros
- 25:47Tab completion using argparse decorators
- 34:51Embedded Python interpreter
- 35:24Embedded IPython interpreter (opt-in)
- 42:11Asynchronous Alerting
- 44:00Full Unicode support
- 44:25Compatibility
- 44:43Built-in regression testing framework
- 44:58Application Lifecycle Hooks
related talks
01h 28mWriting Compiled PowerShell Cmdlets
33mCLI-Driven Developer Experience: The Secret Ingredient of an Aligned Team
34mThe Power of the Command Line - How Bash Can Boost Your Productivity
19mIt's a UNIX system, I know this!
39mLinux Shell Debates or: How I Stopped Worrying and Learned to Love PowerShell
26mCommand line language – where NLP and cyber security meets
26mCLI, CI, DIY: Crafting Python Based Dev Tools in a DevOps Vacuum
45mNew Shell in Town: Adventures in using PowerShell on Linux
