Coverage for sparkle/configurator/configurator_cli.py: 0%
15 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-27 09:10 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-27 09:10 +0000
1"""Configurator CLI wrapper class to standardise I/O of Configurators."""
3import sys
4import subprocess
5from pathlib import Path
6import implementations
8if __name__ == "__main__":
9 args = sys.argv
10 configurator_name = args[1]
11 output_source = Path(args[2])
12 output_target = Path(args[3])
13 configurator_call = args[4:]
14 # 1. Resolve for which Configurator we are standardising
15 configurator = implementations.resolve_configurator(configurator_name)
16 # 2. Execute the call, output is automatically piped to the caller's set output
17 subprocess.run(configurator_call)
18 # 3. Standardise the output for Sparkle
19 # 3a. Make sure the output file exists
20 output_target.open("a").close()
21 # 3b. Have the configurator implementation organise the output
22 configurator.organise_output(output_source=output_source,
23 output_target=output_target)
24 print(f"Organising done! See {output_target}")