mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[utils] Add cli helper for command line prompts
This commit is contained in:
parent
1d7d0eaa38
commit
09c8d1f80d
13
legendary/utils/cli.py
Normal file
13
legendary/utils/cli.py
Normal 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
|
Loading…
Reference in a new issue