forked from kfdm-archive/thehitlist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_task.py
executable file
·34 lines (29 loc) · 971 Bytes
/
create_task.py
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
34
#!/usr/bin/env python
import TheHitList
from optparse import OptionParser
if __name__ == '__main__':
parser = OptionParser()
parser.add_option("--show", dest="show",
help="Show tasks in a list", default=None)
parser.add_option("--list", dest="list",
help="Add task to a specific list", default=None)
(opts, args) = parser.parse_args()
thl = TheHitList.Application()
if (opts.show):
if opts.show == 'inbox':
list = thl.inbox()
else:
list = thl.find_list(opts.show)
for task in list.tasks():
print (task.title)
exit()
if (len(args) == 0):
parser.error('Missing Task')
newtask = TheHitList.Task()
newtask.title = ' '.join(args)
if opts.list is None:
list = thl.inbox()
else:
list = thl.find_list(opts.list)
list.add_task(newtask)
print ('Task (%s) has been added' % newtask.title)