Coverage for ajallaan/cli.py: 0.00%
27 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-04 15:19:53 +00:00
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-04 15:19:53 +00:00
1"""In due time (Finnish: ajallaan) - reporting on worklog entries of some ticket system - command line interface"""
3import argparse
4import sys
5from typing import no_type_check
7import ajallaan.api as api
8from ajallaan import APP_NAME, APP_VERSION
11@no_type_check
12def parser():
13 """Implementation of command line API returning parser."""
14 impl = argparse.ArgumentParser(
15 description='Showcase (Finnish: vitriini) some packaged content - guided by conventions.'
16 )
17 impl.add_argument(
18 '-q',
19 '--quiet',
20 dest='quiet',
21 action='store_true',
22 help='Be quiet (overrules debug and verbose alike)',
23 )
24 impl.add_argument(
25 '-v',
26 '--verbose',
27 dest='verbose',
28 action='store_true',
29 help='Be more verbose, maybe',
30 )
31 impl.add_argument(
32 '-d',
33 '--debug',
34 dest='debug',
35 action='store_true',
36 help='Support debugging, maybe',
37 )
38 impl.add_argument(
39 '-i',
40 '--input',
41 dest='in_path',
42 type=str,
43 required=False,
44 help='Input path of local data',
45 )
46 impl.add_argument(
47 '-u',
48 '--user',
49 dest='user',
50 type=str,
51 required=False,
52 help='API user account name',
53 )
54 impl.add_argument(
55 '-t',
56 '--token',
57 dest='token',
58 type=str,
59 required=False,
60 help='API token or passphrase',
61 )
62 impl.add_argument(
63 '-w',
64 '--worker',
65 dest='worker',
66 type=str,
67 required=False,
68 help='Worklog user name whose entries to report (default is api user)',
69 )
70 impl.add_argument(
71 '-o',
72 '--output',
73 dest='out_path',
74 type=str,
75 required=False,
76 help='Output path for json report',
77 )
78 return impl
81@no_type_check
82def app(argv=None):
83 """Drive the transformation."""
84 argv = sys.argv[1:] if argv is None else argv
85 arg_parser = parser()
86 if not argv:
87 print(f'{APP_NAME} version {APP_VERSION}')
88 arg_parser.print_help()
89 return 0
91 options = arg_parser.parse_args(argv)
92 return api.process(options)