|
14 | 14 | from .config_generator import ConfigProcessor |
15 | 15 |
|
16 | 16 |
|
| 17 | +class ConfigRunner(object): |
| 18 | + |
| 19 | + def run(self, args): |
| 20 | + parser = self.get_parser() |
| 21 | + opts = parser.parse_args(args) |
| 22 | + cwd = opts.cwd if opts.cwd else os.getcwd() |
| 23 | + filters = opts.filter if opts.filter else () |
| 24 | + excluded_keys = opts.exclude if opts.exclude else () |
| 25 | + if opts.output_file is None: |
| 26 | + opts.print_data = True |
| 27 | + |
| 28 | + config_processor = ConfigProcessor() |
| 29 | + config_processor.process(cwd, opts.path, filters, excluded_keys, opts.enclosing_key, opts.output_format, |
| 30 | + opts.print_data, opts.output_file, opts.skip_interpolation_resolving, |
| 31 | + opts.skip_interpolation_validation) |
| 32 | + |
| 33 | + @staticmethod |
| 34 | + def get_parser(): |
| 35 | + parser = argparse.ArgumentParser() |
| 36 | + parser.add_argument('path', type=str, help='The config directory') |
| 37 | + parser.add_argument('--output-file', dest='output_file', type=str, |
| 38 | + help='output file location') |
| 39 | + parser.add_argument('--format', dest='output_format', type=str, default="yaml", |
| 40 | + help='output file format') |
| 41 | + parser.add_argument('--filter', dest='filter', action='append', |
| 42 | + help='keep these keys from the generated data') |
| 43 | + parser.add_argument('--exclude', dest='exclude', action='append', |
| 44 | + help='exclude these keys from generated data') |
| 45 | + parser.add_argument('--skip-interpolation-validation', action='store_true', |
| 46 | + help='will not throw an error if interpolations can not be resolved') |
| 47 | + parser.add_argument('--skip-interpolation-resolving', action='store_true', |
| 48 | + help='do not perform any AWS calls to resolve interpolations') |
| 49 | + parser.add_argument('--enclosing-key', dest='enclosing_key', type=str, |
| 50 | + help='enclose the generated data under a common key') |
| 51 | + parser.add_argument('--cwd', dest='cwd', type=str, default="", |
| 52 | + help='the working directory') |
| 53 | + return parser |
| 54 | + |
| 55 | + |
17 | 56 | def run(args=None): |
18 | | - """ App entry point """ |
19 | | - |
20 | | - parser = argparse.ArgumentParser() |
21 | | - parser.add_argument('path', type=str, help='The config directory') |
22 | | - parser.add_argument('--output-file', dest='output_file', type=str, |
23 | | - help='output file location') |
24 | | - parser.add_argument('--format', dest='output_format', type=str, default="yaml", |
25 | | - help='output file format') |
26 | | - parser.add_argument('--filter', dest='filter', action='append', |
27 | | - help='keep these keys from the generated data') |
28 | | - parser.add_argument('--exclude', dest='exclude', action='append', |
29 | | - help='exclude these keys from generated data') |
30 | | - parser.add_argument('--skip-interpolation-validation', action='store_true', |
31 | | - help='will not throw an error if interpolations can not be resolved') |
32 | | - parser.add_argument('--skip-interpolation-resolving', action='store_true', |
33 | | - help='do not perform any AWS calls to resolve interpolations') |
34 | | - parser.add_argument('--enclosing-key', dest='enclosing_key', type=str, |
35 | | - help='enclose the generated data under a common key') |
36 | | - parser.add_argument('--cwd', dest='cwd', type=str, default="", |
37 | | - help='the working directory') |
38 | | - |
39 | | - opts = parser.parse_args(args) |
40 | | - cwd = opts.cwd if opts.cwd else os.getcwd() |
41 | | - filters = opts.filter if opts.filter else () |
42 | | - excluded_keys = opts.exclude if opts.exclude else () |
43 | | - print_data = True |
44 | | - |
45 | | - config_processor = ConfigProcessor() |
46 | | - config_processor.process(cwd, opts.path, filters, excluded_keys, opts.enclosing_key, opts.output_format, |
47 | | - print_data, opts.output_file, opts.skip_interpolation_resolving, |
48 | | - opts.skip_interpolation_validation) |
| 57 | + ConfigRunner().run(args) |
0 commit comments