Skip to content

Instantly share code, notes, and snippets.

@phadej
Created November 1, 2012 14:57
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 phadej/3994121 to your computer and use it in GitHub Desktop.
Save phadej/3994121 to your computer and use it in GitHub Desktop.
% cat tar.py
"""
Usage:
tar [-c] [options] <files>...
tar [-r | -u] -f ARCHIEVE [options] <files>...
tar [-t | -x] [options] [<patterns>...]

Options:
   -h            Print this message
   -v            Verbose
   -z            Gzip
   -j            Bzip2
   -b BLOCKSIZE  block size
   -f ARCHIVE    archive file
"""

from docopt import docopt

if __name__ == '__main__':
  arguments = docopt(__doc__, version='0.0.1')
  print(arguments)
% python tar.py -czb 128 -f docopt.gz test1.py test2.py
{'-b': '128',
 '-c': 1,
 '-f': [[['docopt.gz']]],
 '-h': False,
 '-j': False,
 '-r': 0,
 '-t': 0,
 '-u': 0,
 '-v': False,
 '-x': 0,
 '-z': True,
 '<files>': ['test1.py', 'test2.py'],
 '<patterns>': []}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment