aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:13 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 02:29:13 +0100
commiteed3dbada43ff6271bdf550883d38e08a6b29788 (patch)
treef2c263a547ff29cefd522f7adb624bf1ac56d03e /bin
parentca0015ebf89baa1f8adfcefde4a91a7e22dd4ff2 (diff)
Added -a|--auto CLI argument.
An user may now specify simulation's auto-save interval during initialization. This works for both new and loaded simulations.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/salis.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/salis.py b/bin/salis.py
index 3e3bacc..eef4263 100755
--- a/bin/salis.py
+++ b/bin/salis.py
@@ -37,8 +37,9 @@ class Salis:
and parsed with the 'argparse' module. Library is loaded with 'CDLL'
and C headers are parsed to detect function argument and return types.
"""
- # Before declaring any other privates, let's define the absolute path
- # and parse CLI arguments.
+ # Before declaring any other privates, let's define the autosave
+ # member, get the absolute path and parse CLI arguments.
+ self.autosave = "---"
self.path = self.__get_path()
self.args = self.__parse_args()
@@ -51,7 +52,6 @@ class Salis:
self.printer = Printer(self)
self.handler = Handler(self)
self.state = "paused"
- self.autosave = "---"
# Based on CLI arguments, initialize a new Salis simulation or load
# existing one from file.
@@ -208,6 +208,10 @@ class Salis:
"-f", "--file", required=True, type=str, metavar="FILE",
help="Name of FILE to save simulation to on exit"
)
+ new_parser.add_argument(
+ "-a", "--auto", required=False, type=lambda x: int(x, 0),
+ metavar="INT", help="Auto-save interval for the new simulation"
+ )
# Set up subparser for the 'load' existing action.
load_parser = subparsers.add_parser("load", formatter_class=formatter)
@@ -215,6 +219,10 @@ class Salis:
"-f", "--file", required=True, type=str, metavar="FILE",
help="Load previously saved simulation from FILE"
)
+ load_parser.add_argument(
+ "-a", "--auto", required=False, type=lambda x: int(x, 0),
+ metavar="INT", help="Auto-save interval for the loaded simulation"
+ )
# Finally, parse all arguments.
args = parser.parse_args()
@@ -232,6 +240,11 @@ class Salis:
"Save file provided '{}' does not exist".format(savefile)
)
+ # Set autosave interval, if given.
+ #if args.auto:
+ if args.auto:
+ self.set_autosave(args.auto)
+
return args
def __open_log_file(self):