#!../flask/bin/python """ usage: bug [options] [...] options: -u, --uri ENDPOINT Project API endpoint -h, --help Print this help text -v, --version Print the client version commands: open Open a new ticket list List all open bugs in the project show Show a specific ticket by ID [Not implemented yet:] edit Edit a ticket reopen Reopen a previously closed ticket close Close a ticket lock Lock a ticket, preventing new comments label Apply a label to a ticket See 'bug help ' for more information on a specific command """ from importlib import import_module from subprocess import call from docopt import docopt import sys commands = ['open', 'delete', 'show', 'list', 'edit'] def main(): if args[''] in ['help', None]: if not args['']: print(__doc__.lstrip().rstrip()) else: if args[''][0] in commands: bug_mod = import_module('bug_{}'.format(args[''][0])) print(bug_mod.__doc__.lstrip().rstrip()) else: sys.exit("'{}' is not a bug.py command. See 'bug help'.".format(args[''][0])) elif args[''] in commands: if not args['--uri']: sys.exit("URI missing") bug_mod = import_module('bug_{}'.format(args[''])) arg = {'--uri': args['--uri']} arg.update(docopt(bug_mod.__doc__, argv=[args['']] + args[''])) bug_mod.entrypoint(arg) else: sys.exit("'{}' is not a bug.py command. See 'bug help'.".format(args[''])) if __name__ == '__main__': args = docopt(__doc__, version='tbt client version 0.0.0.alpha', options_first=True) #print(args) main()