Todd Leonhardt

Todd Leonhardt

Senior Cyber Engineer II


I am a professional software developer with 15 years experience developing embedded, desktop, and mobile applications in Python, C++, C, and Java.

Talk: How to quickly build feature-rich interactive command-line applications with cmd2

cmd2 is a tool for building interactive command line applications in Python. Its goal is to make it quick and easy for developers to build feature-rich and user-friendly interactive command line applications. It provides a simple API which is an extension of Python’s built-in cmd module. cmd2 provides a wealth of features on top of cmd to make your life easier and eliminates much of the boilerplate code which would be necessary when using cmd.

Main Features
  • Searchable command history (history command and <Ctrl>+r)
  • Text file scripting of your application with load (@) and _relative_load (@@)
  • Python scripting of your application with pyscript
  • Run shell commands with !
  • Pipe command output to shell commands with |
  • Redirect command output to file with >>>; input from file with <
  • Bare >>> with no filename send output to paste buffer (clipboard)
  • py enters interactive Python console (opt-in ipy for IPython console)
  • Multi-line, case-insensitive, and abbreviated commands
  • Special-character command shortcuts (beyond cmd’s @ and !)
  • Settable environment parameters
  • Parsing commands with flags
  • Unicode character support (Python 3 only)
  • Good tab-completion of commands, file system paths, and shell commands
  • Python 2.7 and 3.3+ support
  • Linux, macOS and Windows support
  • Trivial to provide built-in help for all commands
  • Built-in regression testing framework for your applications (transcript-based testing)

back to top