Fixed bad CLI argument parsing and added a fail message

This commit is contained in:
Mike 2019-08-03 23:43:02 -07:00
parent a063a55d02
commit fe0c8f18f2

View File

@ -82,9 +82,13 @@ class BackupDiff:
def consume_arguments(self): def consume_arguments(self):
for i in range(1, len(sys.argv)): i = 0
while i < len(sys.argv):
i += 1
arg = sys.argv[i] arg = sys.argv[i]
# print("I:", i, "; arg:", arg)
if arg == "--source-path": if arg == "--source-path":
i, one_path = self.consume_argument_companion(i) i, one_path = self.consume_argument_companion(i)
@ -129,6 +133,12 @@ class BackupDiff:
self.__do_clean_difference_entries = False self.__do_clean_difference_entries = False
self.log("Won't clean Difference entries") self.log("Won't clean Difference entries")
else:
self.log("The heck are you doing?")
self.log("Unsupported argument: " + arg)
self.log("i is: " + str(i))
raise Exception("THE HECK")
@staticmethod @staticmethod
def consume_argument_companion(arg_index): def consume_argument_companion(arg_index):
@ -136,7 +146,9 @@ class BackupDiff:
if companion_index >= len(sys.argv): if companion_index >= len(sys.argv):
raise Exception("Expected argument after", sys.argv[arg_index]) raise Exception("Expected argument after", sys.argv[arg_index])
return companion_index, sys.argv[companion_index] return_index = companion_index
return return_index, sys.argv[companion_index]
def calculate_comparison_items(self): def calculate_comparison_items(self):