#!/usr/bin/env python
'''ook

Usage:
    ook [options] <command> [<args>...]
    ook (-h | --help)
    ook --version

Options:
    -h --help           Show this screen.
       --version        Show version.
'''

# May you recognize your weaknesses and share your strengths.
# May you share freely, never taking more than you give.
# May you find love and love everyone you find.

from docopt import docopt

VERSION = '0.1.0a1'
arguments = docopt(__doc__, version='ghgrep %s' % VERSION, options_first=True)

try:
    command = __import__(arguments['<command>'])
except ImportError as e:
    # Don't error out nicely if we have an import error *inside* the module.
    if e.message == 'No module named %s' % arguments['<command>']:
        exit('Unknown command: %s' % arguments['<command>'])
    else:
        raise

argv = [arguments['<command>']] + arguments['<args>']
command.run(argv)

