Demo application for the docopt and cmd python modules implementing a command-line interface to github gists
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Writing Command Line Tools in Python

The following are my notes for the talk on writing command line applications given to PhillyPUG on July 10, 2013.

Usage Strings

  • uses existing unix conventions (posix!)

Argument Parsing

  • optparse
  • argparse
  • docopt


  • automatic argument parsing
  • help comes for free
  • arguments
  • options
  • commands
    • constant strings
  • Separate options definitions
  • Vladimir Keleshev

Shelling Out

  • Writing Interactive Applications
  • use the cmd module


  • python standard library
  • subclass Cmd
  • set a prompt
  • define operations with do_ functions
  • docstrings become command help
  • help comes for free (again!)