Coverage for sparkle/CLI/load_snapshot.py: 95%
21 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-05 14:48 +0000
1#!/usr/bin/env python3
2"""Sparkle command to load a Sparkle platform from a .zip file."""
3import sys
4import argparse
5from pathlib import Path
7from sparkle.CLI.help import snapshot_help
8from sparkle.CLI.help import logging as sl
9from sparkle.CLI.help import argparse_custom as ac
10from sparkle.CLI.help import global_variables as gv
13def parser_function() -> argparse.ArgumentParser:
14 """Define the command line arguments."""
15 parser = argparse.ArgumentParser(description="Load a platform from a zip file.")
16 parser.add_argument(*ac.SnapshotArgument.names,
17 **ac.SnapshotArgument.kwargs)
18 return parser
21def main(argv: list[str]) -> None:
22 """Main function of the command."""
23 # Log command call
24 sl.log_command(sys.argv)
26 # Define command line arguments
27 parser = parser_function()
28 # Process command line arguments
29 args = parser.parse_args(argv)
30 snapshot_help.load_snapshot(Path(args.snapshot_file_path))
31 # Reset Global variables as they should be re-read from snapshot
32 gv.__settings = None
33 gv.__latest_scenario = None
34 sys.exit(0)
37if __name__ == "__main__":
38 main(sys.argv[1:])