diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-26 22:59:31 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-26 22:59:31 -0400 |
commit | 7b334ecf9b189c96644d599c84eb6d0fdc5ddddf (patch) | |
tree | c00bafcb02d9ae59091a202c4be1115812cf28f8 /cmd2/parsing.py | |
parent | 3b5c671b40d6b69315fd1c8f85f638e7b0bd6ab8 (diff) | |
download | cmd2-git-7b334ecf9b189c96644d599c84eb6d0fdc5ddddf.tar.gz |
More unit tests for aliases and macros
Diffstat (limited to 'cmd2/parsing.py')
-rw-r--r-- | cmd2/parsing.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/cmd2/parsing.py b/cmd2/parsing.py index 82e8ee39..498834cf 100644 --- a/cmd2/parsing.py +++ b/cmd2/parsing.py @@ -291,7 +291,7 @@ class StatementParser: expr = r'\A\s*(\S*?)({})'.format(second_group) self._command_pattern = re.compile(expr) - def is_valid_command(self, word: str, allow_shortcut: bool) -> Tuple[bool, str]: + def is_valid_command(self, word: str) -> Tuple[bool, str]: """Determine whether a word is a valid name for a command. Commands can not include redirection characters, whitespace, @@ -311,12 +311,11 @@ class StatementParser: if not word: return False, 'cannot be an empty string' - if not allow_shortcut: - errmsg = 'cannot start with a shortcut: ' - errmsg += ', '.join(shortcut for (shortcut, expansion) in self.shortcuts) - for (shortcut, expansion) in self.shortcuts: - if word.startswith(shortcut): - return False, errmsg + errmsg = 'cannot start with a shortcut: ' + errmsg += ', '.join(shortcut for (shortcut, expansion) in self.shortcuts) + for (shortcut, expansion) in self.shortcuts: + if word.startswith(shortcut): + return False, errmsg errmsg = 'cannot contain: whitespace, quotes, ' errchars = [] |