-
Notifications
You must be signed in to change notification settings - Fork 124
Closed
Description
summary
when a do_ command is decorated with @cmd2.with_argparser it does not correctly remove trailing comments.
For example:
@cmd2.with_argparser( system_argument_parser )
def do_system( self, args: argparse.Namespace ):
do_system( args, self._model )and given the command:
(no system selected) > system select <TAB>
almalinux-9.3 centos-7 darwin-22 debian-12 ubuntu-22.04
(no system selected) > system select almalinux-9.3 # hello
Usage: system {list, select, image, container} ...
Error: unrecognized arguments: # hello
(no system selected) >
We get the "unrecognized arguments" error.
This seems to be corrected by this change:
diff --git a/cmd2/parsing.py b/cmd2/parsing.py
index fc28b634..0c39eca3 100755
--- a/cmd2/parsing.py
+++ b/cmd2/parsing.py
@@ -35,7 +35,7 @@ def shlex_split(str_to_split: str) -> List[str]:
:param str_to_split: the string being split
:return: A list of tokens
"""
- return shlex.split(str_to_split, comments=False, posix=False)
+ return shlex.split(str_to_split, comments=True, posix=False)version
python 3.12, cmd2 2.4.3
Metadata
Metadata
Assignees
Labels
No labels