Coverage for vitriini/cli.py: 84.38%
24 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-05 19:54:27 +00:00
« prev ^ index » next coverage.py v7.4.1, created at 2024-02-05 19:54:27 +00:00
1"""Showcase (Finnish: vitriini) some packaged content - guided by conventions - command line interface."""
3import argparse
4import sys
5from typing import no_type_check
7import vitriini.api as api
8from vitriini 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 '-v',
19 '--verbose',
20 dest='verbose',
21 action='store_true',
22 help='Be more verbose, maybe',
23 )
24 impl.add_argument(
25 '-d',
26 '--debug',
27 dest='debug',
28 action='store_true',
29 help='Support debugging, maybe',
30 )
31 impl.add_argument(
32 '-i',
33 '--input',
34 dest='archive_path',
35 type=str,
36 help='Archive path',
37 )
38 return impl
41@no_type_check
42def app(argv=None):
43 """Drive the transformation."""
44 argv = sys.argv[1:] if argv is None else argv
45 arg_parser = parser()
46 if not argv: 46 ↛ 51line 46 didn't jump to line 51, because the condition on line 46 was never false
47 print(f'{APP_NAME} version {APP_VERSION}')
48 arg_parser.print_help()
49 return 0
51 options = arg_parser.parse_args(argv)
52 return api.process(options)
55if __name__ == '__main__': 55 ↛ 56line 55 didn't jump to line 56, because the condition on line 55 was never true
56 sys.exit(app(sys.argv[1:]))