diff options
Diffstat (limited to 'client/bug.py')
-rwxr-xr-x | client/bug.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/client/bug.py b/client/bug.py new file mode 100755 index 0000000..24a523c --- /dev/null +++ b/client/bug.py @@ -0,0 +1,58 @@ +#!../flask/bin/python +""" +usage: bug [options] <command> [<args>...] + +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:] + resolution Set the resolution status of a ticket + 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 <command>' for more information on a specific command +""" +from importlib import import_module +from subprocess import call +from docopt import docopt + +commands = ['open', 'delete', 'show', 'list', 'edit'] +def main(): + + if args['<command>'] in ['help', None]: + if not args['<args>']: + print(__doc__.lstrip().rstrip()) + else: + if args['<args>'][0] in commands: + bug_mod = import_module('bug_{}'.format(args['<args>'][0])) + print(bug_mod.__doc__.lstrip().rstrip()) + else: + exit("'{}' is not a bug.py command. See 'bug help'.".format(args['<args>'][0])) + elif args['<command>'] in commands: + if not args['--uri']: + exit("URI missing") + + bug_mod = import_module('bug_{}'.format(args['<command>'])) + argv = [args['<command>']] + args['<args>'] + arguments = args.copy() + arguments.update(docopt(bug_mod.__doc__, argv=argv)) + bug_mod.call(arguments) + else: + exit("'{}' is not a bug.py command. See 'bug help'.".format(args['<command>'])) + +if __name__ == '__main__': + args = docopt(__doc__, + version='tbt client version 0.0.0.alpha', + options_first=True) + #print(args) + main() |