Changed order of arguments for query script

This commit is contained in:
mj 2022-01-12 14:03:11 +01:00
parent 053a24146b
commit 12dca6c778

View File

@ -60,18 +60,20 @@ while arg_index < len(argv):
continue continue
elif not action: elif not action:
action = argv[arg_index] action = argv[arg_index]
elif action == 'write' and value == None:
try:
value = int(argv[arg_index])
except ValueError:
print(f'Wrong format for argument "value"')
exit(-3)
else: else:
# rest of the arguments should be register numbers/names # if action is write, last argument should be value
try: if action == 'write' and arg_index == len(argv) - 1:
register_number.append(int(argv[arg_index])) try:
except ValueError: value = int(argv[arg_index])
register_name.append(argv[arg_index]) except ValueError:
print(f'Wrong format for argument "value"')
exit(-3)
else:
# rest of the arguments should be register numbers/names
try:
register_number.append(int(argv[arg_index]))
except ValueError:
register_name.append(argv[arg_index])
arg_index += 1 arg_index += 1