mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 01:45:28 +00:00
[utils] Fix get_integer_choice behaviour
In my defense, the original function was 100% generated by GitHub Copilot.
This commit is contained in:
parent
cd74af8832
commit
d70f0daa22
|
@ -21,15 +21,15 @@ def get_int_choice(prompt, default=None, min_choice=None, max_choice=None, retur
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
choice = int(input(prompt))
|
inp = input(prompt)
|
||||||
except ValueError:
|
if not inp:
|
||||||
if default is not None:
|
|
||||||
return default
|
return default
|
||||||
else:
|
choice = int(inp)
|
||||||
if return_on_invalid:
|
except ValueError:
|
||||||
return None
|
if return_on_invalid:
|
||||||
return_on_invalid = True
|
return None
|
||||||
continue
|
return_on_invalid = True
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
if min_choice is not None and choice < min_choice:
|
if min_choice is not None and choice < min_choice:
|
||||||
print(f'Number must be greater than {min_choice}')
|
print(f'Number must be greater than {min_choice}')
|
||||||
|
|
Loading…
Reference in a new issue