|
|
|
@ -55,11 +55,7 @@ def handle_input(
|
|
|
|
|
return default if default is not NotImplemented else ""
|
|
|
|
|
if default is not NotImplemented:
|
|
|
|
|
console.print(
|
|
|
|
|
"[green]"
|
|
|
|
|
+ message
|
|
|
|
|
+ '\n[blue bold]The default value is "'
|
|
|
|
|
+ str(default)
|
|
|
|
|
+ '"\nDo you want to use it?(y/n)'
|
|
|
|
|
"[green]" + message + '\n[blue bold]The default value is "' + str(default) + '"\nDo you want to use it?(y/n)'
|
|
|
|
|
)
|
|
|
|
|
if input().casefold().startswith("y"):
|
|
|
|
|
return default
|
|
|
|
@ -72,9 +68,7 @@ def handle_input(
|
|
|
|
|
if check_type is not False:
|
|
|
|
|
try:
|
|
|
|
|
user_input = check_type(user_input)
|
|
|
|
|
if (nmin is not None and user_input < nmin) or (
|
|
|
|
|
nmax is not None and user_input > nmax
|
|
|
|
|
):
|
|
|
|
|
if (nmin is not None and user_input < nmin) or (nmax is not None and user_input > nmax):
|
|
|
|
|
# FAILSTATE Input out of bounds
|
|
|
|
|
console.print("[red]" + oob_error)
|
|
|
|
|
continue
|
|
|
|
@ -90,9 +84,7 @@ def handle_input(
|
|
|
|
|
continue
|
|
|
|
|
else:
|
|
|
|
|
# FAILSTATE Input STRING out of bounds
|
|
|
|
|
if (nmin is not None and len(user_input) < nmin) or (
|
|
|
|
|
nmax is not None and len(user_input) > nmax
|
|
|
|
|
):
|
|
|
|
|
if (nmin is not None and len(user_input) < nmin) or (nmax is not None and len(user_input) > nmax):
|
|
|
|
|
console.print("[red bold]" + oob_error)
|
|
|
|
|
continue
|
|
|
|
|
break # SUCCESS Input STRING in bounds
|
|
|
|
@ -106,16 +98,8 @@ def handle_input(
|
|
|
|
|
isinstance(eval(user_input), check_type)
|
|
|
|
|
return check_type(user_input)
|
|
|
|
|
except:
|
|
|
|
|
console.print(
|
|
|
|
|
"[red bold]"
|
|
|
|
|
+ err_message
|
|
|
|
|
+ "\nValid options are: "
|
|
|
|
|
+ ", ".join(map(str, options))
|
|
|
|
|
+ "."
|
|
|
|
|
)
|
|
|
|
|
console.print("[red bold]" + err_message + "\nValid options are: " + ", ".join(map(str, options)) + ".")
|
|
|
|
|
continue
|
|
|
|
|
if user_input in options:
|
|
|
|
|
return user_input
|
|
|
|
|
console.print(
|
|
|
|
|
"[red bold]" + err_message + "\nValid options are: " + ", ".join(map(str, options)) + "."
|
|
|
|
|
)
|
|
|
|
|
console.print("[red bold]" + err_message + "\nValid options are: " + ", ".join(map(str, options)) + ".")
|
|
|
|
|