From 09c8d1f80dcc6a13bdbf235943e4b87e13255e32 Mon Sep 17 00:00:00 2001 From: derrod Date: Fri, 29 May 2020 23:04:58 +0200 Subject: [PATCH] [utils] Add cli helper for command line prompts --- legendary/utils/cli.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 legendary/utils/cli.py diff --git a/legendary/utils/cli.py b/legendary/utils/cli.py new file mode 100644 index 0000000..c044144 --- /dev/null +++ b/legendary/utils/cli.py @@ -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