diff options
author | Rob Austein <sra@hactrn.net> | 2010-03-05 14:37:39 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2010-03-05 14:37:39 +0000 |
commit | 714d52e61391c1e4f9d302d6ffd12a39f183f008 (patch) | |
tree | 702395720b4ea1c7f306b69f859fa71a323f18ab /rpkid | |
parent | 73b4f3152d8cf5c30dc09b28933514892be8264c (diff) |
yes_or_no()
svn path=/rpkid/rpki/cli.py; revision=3029
Diffstat (limited to 'rpkid')
-rw-r--r-- | rpkid/rpki/cli.py | 15 |
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"' + + |