-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.py
98 lines (89 loc) · 2.91 KB
/
cli.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""
Module that contains the command line app.
Why does this file exist, and why not put this in __main__?
You might be tempted to import things from __main__ later, but that will cause
problems: the code will get executed twice:
- When you run `python -mjournal_software_engineering` python will execute
``__main__.py`` as a script. That means there won't be any
``journal_software_engineering.__main__`` in ``sys.modules``.
- When you import __main__ it will get executed again (as a module) because
there's no ``journal_software_engineering.__main__`` in ``sys.modules``.
Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration
"""
import argparse
from journal_software_engineering.journal import Journal
from journal_software_engineering.journal import last_business_day
parser = argparse.ArgumentParser(
prog='journal',
description='''
journal that provides functionality for generic,
note, ticket, and todo journal entry and lookup
functionality''',
epilog='made by sage smith'
)
parser.add_argument(
'entry', nargs='?', type=str,
help='entry to enter in journal'
)
parser.add_argument(
'-t', '--ticket', action='store_true',
help='specifies ticket journal'
)
parser.add_argument(
'-d', '--do', action='store_true',
help='specifies todo journal'
)
parser.add_argument(
'-n', '--note', action='store_true',
help='specifies note journal'
)
parser.add_argument(
'-c', '--complete', action='store_true',
help='makes a completed entry in journal'
)
parser.add_argument(
'-s', '--standup', action='store_true',
help='prints stand up'
)
parser.add_argument(
'-j', '--journal', action='store_true',
help='specifies entire journal'
)
parser.add_argument(
'-b', '--before', type=str,
help='''
specifies to grab standup logs before entered date
format: YYYY-MM-DD
'''
)
parser.add_argument(
'-a', '--after', type=str,
help='''
specifies to grab standup logs after entered date
default: last business day | format: YYYY-MM-DD
''',
default=last_business_day()
)
def main(args=None):
print('here')
args = parser.parse_args()
j = Journal()
if args.standup:
if args.ticket:
j.standup(j.ticket_repo, args.before, args.after)
if args.do:
j.standup(j.todo_repo, args.before, args.after)
if args.note:
j.standup(j.notes_repo, args.before, args.after)
if not args.ticket and not args.do and not args.note or args.journal: # NOQA
j.standup(j.journal_repo, args.before, args.after)
else:
if args.ticket:
j.ticket_entry(args.entry)
if args.do:
j.todo_entry(args.entry)
if args.note:
j.notes_entry(args.entry)
if not args.ticket and not args.do and not args.note or args.journal: # NOQA
j.journal_entry(args.entry)
parser.print_help()