summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2/cmd2.py')
-rwxr-xr-xcmd2/cmd2.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index d82e58c9..305c4173 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 cmd in self.get_all_commands():
+ valid, errmsg = self.statement_parser.is_valid_command(cmd)
+ if not valid:
+ raise ValueError("Invalid command name {!r}: {}".format(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