Coverage for gws-app/gws/spec/spec.py: 0%
25 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""Command line tool that runs the spec generator on the developer system."""
3import os
4import sys
6sys.path.insert(0, os.path.abspath(os.path.dirname(__file__) + '/../../../app'))
8import gws.lib.cli as cli
10import gws.spec.generator.main as generator_main
12USAGE = """
13GWS Spec Compiler
14~~~~~~~~~~~~~~~~~
16 python3 spec.py <output-directory> <options>
18Options:
20 -root <dir>
21 application root directory ('app')
23 -manifest <path>
24 path to MANIFEST.json
26 -v
27 verbose logging
28"""
31def main(args):
32 """Generate the specs and write them to the output directory.
34 Args:
35 args: Parsed command line arguments: the output directory as the first
36 positional argument, and the ``root``, ``manifest`` and ``v`` options.
38 Raises:
39 ``generator_main.Error``: If the generator fails; other exceptions are passed through as well.
40 """
42 out_dir = args.get(1)
43 if not out_dir:
44 cli.fatal('output directory required')
46 os.makedirs(out_dir, exist_ok=True)
48 try:
49 generator_main.generate_and_write(
50 out_dir=out_dir,
51 root_dir=args.get('root'),
52 manifest_path=args.get('manifest'),
53 debug=args.get('v'))
55 except generator_main.Error as e:
56 cli.error('-' * 40)
57 cli.error(f'SPEC GENERATOR ERROR: {e.args[0]}')
58 cli.error('-' * 40)
59 raise
60 except Exception as e:
61 cli.error('-' * 40)
62 cli.error(f'UNHANDLED SPEC GENERATOR ERROR: {e!r}')
63 cli.error('-' * 40)
64 raise
67if __name__ == '__main__':
68 cli.main('spec', main, USAGE)