aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rpkid/rpki/cli.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/rpkid/rpki/cli.py b/rpkid/rpki/cli.py
index 32844896..19ef367c 100644
--- a/rpkid/rpki/cli.py
+++ b/rpkid/rpki/cli.py
@@ -80,3 +80,18 @@ class Cmd(cmd.Cmd):
else:
cmdloop_with_history = cmd.Cmd.cmdloop
+
+
+def yes_or_no(prompt, full_word_required = False):
+ """
+ Ask a yes-or-no question.
+ """
+ while True:
+ answer = raw_input(prompt).strip().lower()
+ if answer == "yes" or (not full_word_required and answer[0] == "y"):
+ return True
+ if answer == "no" or (not full_word_required and answer[0] == "n"):
+ return False
+ print 'Please answer "yes" or "no"'
+
+