diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-16 00:41:29 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-16 00:41:29 -0500 |
commit | 1f539c5729f005f0c4310918530a7bee78eacd8d (patch) | |
tree | 84134fe0fe1f866a6ec90327de588dd794c588ca /cmd2.py | |
parent | 49059cb336ef775f27b33747e06e390c9c4ae3a1 (diff) | |
download | cmd2-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-x | cmd2.py | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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")]) |