1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2025-12-07 09:03:06 +00:00
kiwi-scp/src/kiwi/subcommands/utils/user_input.py

30 lines
709 B
Python
Raw Normal View History

2020-08-17 13:21:42 +00:00
def _surround(string, bang):
midlane = f"{bang * 3} {string} {bang * 3}"
sidelane = bang*len(midlane)
return f"{sidelane}\n{midlane}\n{sidelane}"
2020-08-17 12:51:11 +00:00
def are_you_sure(prompt, default="no"):
if default.lower() == 'yes':
suffix = "[YES|no]"
else:
suffix = "[yes|NO]"
answer = input(
2020-08-17 13:21:42 +00:00
f"{_surround('CAREFULING IN PROGRESS', '!')}\n"
f"\n"
f">>> {prompt} <<<\n"
f"\n"
2020-08-17 12:51:11 +00:00
f"Are you sure you want to proceed? {suffix} "
).strip().lower()
if answer == '':
answer = default
while answer not in ['yes', 'no']:
answer = input("Please type 'yes' or 'no' explicitly: ").strip().lower()
return answer == 'yes'