[utils] Add cli helper for command line prompts

This commit is contained in:
derrod 2020-05-29 23:04:58 +02:00
parent 1d7d0eaa38
commit 09c8d1f80d

13
legendary/utils/cli.py Normal file
View file

@ -0,0 +1,13 @@
def get_boolean_choice(prompt, default=True):
if default:
yn = 'Y/n'
else:
yn = 'y/N'
choice = input(f'{prompt} [{yn}]: ')
if not choice:
return default
elif choice[0].lower() == 'y':
return True
else:
return False