Skip to content

Instantly share code, notes, and snippets.

@byrney
Created November 14, 2016 06:59
Show Gist options
  • Save byrney/65bcbb095c8056e054c9a87f02ef8c59 to your computer and use it in GitHub Desktop.
Save byrney/65bcbb095c8056e054c9a87f02ef8c59 to your computer and use it in GitHub Desktop.
Python docopt example
"""
Usage:
program run [options] [--] (FILE... | --stdin)
program load [options] [--] (FILE... | --stdin)
Options:
-d DATABASE --database=DATABASE Specify database
-v --verbose Be verbose
-h --help Show this screen.
-V --version Version information
"""
import sys
if __name__ == '__main__':
import docopt
args = docopt.docopt(__doc__.replace('program', sys.argv[0]), version='Command 0.1')
print(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment