home · contact · privacy
Server/py: Add command line parser for replay option.
[plomrogue] / plomrogue-server.py
index 2c9e70153077c1de9df54335c7d264260577733a..1e4eda149eaa69451e865ca2dca1d2e0a6366bcb 100755 (executable)
@@ -1,3 +1,4 @@
+import argparse
 import errno
 import os
 import time
@@ -46,7 +47,7 @@ def cleanup_server_io(io_db):
 
 
 def detect_atomic_leftover(path):
-    """Raise HandledException if file is found at path + "_tmp"."""
+    """Raise explained HandledException if file is found at path + "_tmp"."""
     path_tmp = path + "_tmp"
     msg = "Found file '" + path_tmp + "' that may be a leftover from an " \
           "aborted previous attempt to write '" + path + "'. Aborting until " \
@@ -57,6 +58,11 @@ def detect_atomic_leftover(path):
 
 io_db = {}
 try:
+    parser = argparse.ArgumentParser(add_help=False)
+    parser.add_argument('-s', nargs='?', type=int, dest='replay', const=1,
+                        action='store')
+    args, unknown = parser.parse_known_args()
+    print("Replay: " + str(args.replay))
     print("DUMMY: Obey command-line arguments.")
     print("DUMMY: Open files.")
     setup_server_io(io_db)