Coverage for sparkle/CLI/save_snapshot.py: 94%

17 statements  

« 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 save the current Sparkle platform in a .zip file.""" 

3import sys 

4 

5from sparkle.CLI.help import snapshot_help 

6from sparkle.CLI.help import logging as sl 

7from sparkle.CLI.help import argparse_custom as ac 

8import argparse 

9 

10 

11def parser_function() -> argparse.ArgumentParser: 

12 """Parser for save_snapshot.""" 

13 parser = argparse.ArgumentParser( 

14 description="Save the current platform in a .zip file.", 

15 epilog="Can be loaded later with the load snapshot command.") 

16 parser.add_argument(*ac.SnapshotNameArgument.names, 

17 **ac.SnapshotNameArgument.kwargs) 

18 return parser 

19 

20 

21def main(argv: list[str]) -> None: 

22 """Main function of the command.""" 

23 # Log command call 

24 sl.log_command(sys.argv) 

25 parser = parser_function() 

26 args = parser.parse_args(argv) 

27 snapshot_help.save_current_platform(args.name) 

28 sys.exit(0) 

29 

30 

31if __name__ == "__main__": 

32 main(sys.argv[1:])