Commit 8f042edd authored by Benjamin Winger's avatar Benjamin Winger

migrate: Added option to ignore mods when choosing between ambiguous mods

parent 734ef7ff
......@@ -120,7 +120,9 @@ def migrate():
mods.append((path, modq.get().item))
elif modq.qsize() > 1:
if args.interactive:
mods.append(prompt_mods(path, modq))
result = prompt_mods(path, modq)
if result is not None:
mods.append(result)
else:
ambiguousmods.append((path, modq.get().item))
else:
......@@ -129,7 +131,9 @@ def migrate():
fuzzymods.append((path, fuzzymodq.get().item))
elif fuzzymodq.qsize() > 1:
if args.interactive:
mods.append(prompt_mods(path, fuzzymodq))
result = prompt_mods(path, fuzzymodq)
if result is not None:
mods.append(result)
else:
ambiguousfuzzymods.append((path, fuzzymodq.get().item))
else:
......@@ -219,7 +223,8 @@ def prompt_mods(path, modq):
desc = (
"The above mods partially matched the mod "
"installed at {}. Higher priority means closer match.\n"
"Which would you like to select? 0 - {}".format(path, modq.qsize())
"Which would you like to select? 0 - {}, "
"or -1 to select none".format(path, modq.qsize() - 1)
)
modlist = []
......@@ -232,7 +237,9 @@ def prompt_mods(path, modq):
display_search_results([pitem.item])
i += 1
index = prompt_num(desc, len(modlist))
index = prompt_num(desc, len(modlist), cancel=True)
if index == -1:
return None
return (path, modlist[index].item)
......
......@@ -58,12 +58,15 @@ def prompt_num_multi(question, max_val):
)
def prompt_num(question, max_val):
def prompt_num(question, max_val, cancel=False):
print("{}: ".format(question))
while True:
try:
result = int(input())
if result > max_val or result < 0:
if result == -1 and cancel:
return result
print(
"Please ensure that the number is between 0 and {}".format(max_val)
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment