diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-08-07 20:37:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-07 20:37:55 -0400 |
commit | e017028bff4ed9c552aa0f79f86b878d2c616456 (patch) | |
tree | 8af2ef1f3bd3d73f1116bbe88b886aae67b13230 /cmd2/cmd2.py | |
parent | cc3d5cd210902e899ee34cd4f71c344fdc075ecb (diff) | |
parent | 933e328c04dcaf842c5fc8b536879902cbc11bea (diff) | |
download | cmd2-git-e017028bff4ed9c552aa0f79f86b878d2c616456.tar.gz |
Merge pull request #755 from python-cmd2/verify_command_names
Verifying command names in __init__
Diffstat (limited to 'cmd2/cmd2.py')
-rwxr-xr-x | cmd2/cmd2.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index a7cd8fac..4a5c506d 100755 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -448,6 +448,12 @@ class Cmd(cmd.Cmd): multiline_commands=multiline_commands, shortcuts=shortcuts) + # Verify commands don't have invalid names (like starting with a shortcut) + for cur_cmd in self.get_all_commands(): + valid, errmsg = self.statement_parser.is_valid_command(cur_cmd) + if not valid: + raise ValueError("Invalid command name {!r}: {}".format(cur_cmd, errmsg)) + # Stores results from the last command run to enable usage of results in a Python script or interactive console # Built-in commands don't make use of this. It is purely there for user-defined commands and convenience. self.last_result = None |