Skip to content

Instantly share code, notes, and snippets.

@scholer
Last active July 24, 2017 16:12
Show Gist options
  • Save scholer/fbfdaa1fb30ad296cb6b06b0446a2307 to your computer and use it in GitHub Desktop.
Save scholer/fbfdaa1fb30ad296cb6b06b0446a2307 to your computer and use it in GitHub Desktop.
Python CLI: Command line argument parsing packages

Command line argument parsing alternatives, overview:

  • getopt - the old, original command line argument parser.
  • optparse - Complex Python 2.6 replacement for getopt, before being replaced by argparse.
  • argparse - The current standard library command line argument parser.
  • docopt - Write program docstring, parse docstring with docopt to produce CLI.
  • click - CLI arguments via function decorators. Aims at high composability and nesting complexity.
  • clize - clize.run(hello_world)
  • defopt - Lightweight, no-effort argument parser. defopt.run(main)
  • fire - Generate command line interfaces (CLIs) from any Python object. For instance, use class to define CLI subcommands: fire.Fire(Calculator)
  • begins - Also based on function decorators, but uses function arguments. No updates since 2014 :(
  • argh - Argh is a smart wrapper for argparse. argh.dispatch_command(main)
  • aaargh - "This project is no longer maintained! Use click."
  • invoke - Designed for task execution, but can be fitted for use as CLI as well.
  • plac, etc.

Refs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment