summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-16 00:41:29 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-02-16 00:41:29 -0500
commit1f539c5729f005f0c4310918530a7bee78eacd8d (patch)
tree84134fe0fe1f866a6ec90327de588dd794c588ca /cmd2.py
parent49059cb336ef775f27b33747e06e390c9c4ae3a1 (diff)
downloadcmd2-git-1f539c5729f005f0c4310918530a7bee78eacd8d.tar.gz
Deal with select index out of range.
This is a fix for issue #17
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd2.py b/cmd2.py
index 9127269b..dacc0526 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1195,8 +1195,9 @@ class Cmd(cmd.Cmd):
response = int(response)
result = fulloptions[response - 1][0]
break
- except ValueError:
- pass # loop and ask again
+ except (ValueError, IndexError):
+ self.stdout.write("{!r} isn't a valid choice. Pick a number between 1 and {}:\n".format(response,
+ len(fulloptions)))
return result
@options([make_option('-l', '--long', action="store_true", help="describe function of parameter")])