diff options
| author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-02-16 00:47:21 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-16 00:47:21 -0500 |
| commit | fa4120d31e972e92b101505611e0e932c7ef1fc3 (patch) | |
| tree | 84134fe0fe1f866a6ec90327de588dd794c588ca | |
| parent | 49059cb336ef775f27b33747e06e390c9c4ae3a1 (diff) | |
| parent | 1f539c5729f005f0c4310918530a7bee78eacd8d (diff) | |
| download | cmd2-git-fa4120d31e972e92b101505611e0e932c7ef1fc3.tar.gz | |
Merge pull request #46 from python-cmd2/select_index
Deal with select index out of range.
| -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")]) |
