1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
|
4
|
|
|
"""Simple read-only Thing 3 CLI.""" |
5
|
|
|
|
6
|
|
|
from __future__ import print_function |
7
|
|
|
|
8
|
|
|
__author__ = "Alexander Willner" |
9
|
|
|
__copyright__ = "2020 Alexander Willner" |
10
|
|
|
__credits__ = ["Alexander Willner"] |
11
|
|
|
__license__ = "Apache" |
12
|
|
|
__version__ = "0.0.1" |
13
|
|
|
__maintainer__ = "Alexander Willner" |
14
|
|
|
__email__ = "[email protected]" |
15
|
|
|
__status__ = "Development" |
16
|
|
|
|
17
|
|
|
import argparse |
18
|
|
|
import things3 |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
class Things3CLI(): |
22
|
|
|
"""Simple read-only Thing 3 CLI.""" |
23
|
|
|
|
24
|
|
|
def print_today(self): |
25
|
|
|
"""Show Today.""" |
26
|
|
|
tasks = things3.get_today() |
27
|
|
|
for task in tasks: |
28
|
|
|
print(' - ' + task[1]) |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
def main(args): |
32
|
|
|
""" Main entry point of the app """ |
33
|
|
|
if args.command == 'Today': |
34
|
|
|
Things3CLI().print_today() |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
if __name__ == "__main__": |
38
|
|
|
PARSER = argparse.ArgumentParser() |
39
|
|
|
|
40
|
|
|
# Required positional argument |
41
|
|
|
PARSER.add_argument("command", |
42
|
|
|
help="Inbox, Today, Scheduled, Waiting, ...") |
43
|
|
|
|
44
|
|
|
# Optional argument which requires a parameter (eg. -d test) |
45
|
|
|
PARSER.add_argument("-w", "--waiting", action="store", dest="waiting_tag") |
46
|
|
|
|
47
|
|
|
# Optional verbosity counter (eg. -v, -vv, -vvv, etc.) |
48
|
|
|
PARSER.add_argument( |
49
|
|
|
"-v", |
50
|
|
|
"--verbose", |
51
|
|
|
action="count", |
52
|
|
|
default=0, |
53
|
|
|
help="Verbosity (-v, -vv, etc)") |
54
|
|
|
|
55
|
|
|
# Specify output of "--version" |
56
|
|
|
PARSER.add_argument( |
57
|
|
|
"--version", |
58
|
|
|
action="version", |
59
|
|
|
version="%(prog)s (version {version})".format(version=__version__)) |
60
|
|
|
|
61
|
|
|
MYARGS = PARSER.parse_args() |
62
|
|
|
main(MYARGS) |
63
|
|
|
|