summaryrefslogtreecommitdiffstats
path: root/client/bug_list.py
blob: 87e60d8c26e7432db0161a04ea2e583f833d1402 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!../flask/bin/python
"""
usage: bug list [options]

If no arguments are given it will open your $EDITOR where the first line is
the summary following a newline and then the body of the report.  Both are
required.

    -h, --help            Print this help text
"""
from docopt import docopt
from textwrap import indent
from datetime import datetime
from bug_show import show_ticket
import json, requests, sys

if __name__ == '__main__':
	print(docopt(__doc__))

def entrypoint(args):
	print(args)
	api_endpoint = args['--uri'] + '/api/1.0/tickets'

	r = requests.get(api_endpoint, verify=False)

	tickets = json.loads(r.text)
	if not tickets:
		sys.exit("No tickets found.")

	tickets = tickets.get('tickets')

	for ticket in tickets:
		print(show_ticket(ticket))