Skip to content

Instantly share code, notes, and snippets.

@chrisb13
Last active October 7, 2015 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisb13/a1e813302a0c9fbd9759 to your computer and use it in GitHub Desktop.
Save chrisb13/a1e813302a0c9fbd9759 to your computer and use it in GitHub Desktop.
snippet docopt
#see: https://github.com/docopt/docopt
#round brackets mean required square are optional
#download docopt from...
#https://raw.githubusercontent.com/docopt/docopt/master/docopt.py
`!p
import inspect,os
docopt_path=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))+'/docopt.py'
#snip.rv=docopt_path
if not os.path.isfile(docopt_path):
import urllib
urllib.urlretrieve("https://raw.githubusercontent.com/docopt/docopt/master/docopt.py",\
filename=docopt_path)
#ret='downloaded docopt'
#else:
#ret='did not download docopt'
#snip.rv=ret
`
"""
${1:Docstring for file}
Usage:
`!p
snip.rv=' '+snip.fn
` -h
`!p
snip.rv=' '+snip.fn
` ( ${2:first_argument} | ${4:second_argument} )
Options:
-h,--help : show this help message
$2,--${3:Long_version_first_agument} : optional argument
$4 : mandatory argument (capitals or angled brackets)
"""
from docopt import docopt
arguments = docopt(__doc__)
endsnippet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment