summaryrefslogtreecommitdiff
path: root/cmd2/pyscript_bridge.py
diff options
context:
space:
mode:
authorkmvanbrunt <kmvanbrunt@gmail.com>2018-10-11 14:07:50 -0400
committerGitHub <noreply@github.com>2018-10-11 14:07:50 -0400
commit473cb08237b402658e857d786d5294defe721ec7 (patch)
tree322051b16a75531aa8015c494b3f17c5caafee60 /cmd2/pyscript_bridge.py
parentf38e100fd77f4a136a4883d23b2f4f8b3cd934b7 (diff)
parent8bed2448ede91fc5cb7d8ff1044a75650350810e (diff)
downloadcmd2-git-473cb08237b402658e857d786d5294defe721ec7.tar.gz
Merge pull request #573 from python-cmd2/double_dash
Double dash
Diffstat (limited to 'cmd2/pyscript_bridge.py')
-rw-r--r--cmd2/pyscript_bridge.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/cmd2/pyscript_bridge.py b/cmd2/pyscript_bridge.py
index 11a2cbb3..3c5c61f2 100644
--- a/cmd2/pyscript_bridge.py
+++ b/cmd2/pyscript_bridge.py
@@ -12,7 +12,7 @@ import functools
import sys
from typing import List, Callable, Optional
-from .argparse_completer import _RangeAction, token_resembles_flag
+from .argparse_completer import _RangeAction, is_potential_flag
from .utils import namedtuple_with_defaults, StdSim, quote_string_if_needed
# Python 3.4 require contextlib2 for temporarily redirecting stderr and stdout
@@ -222,10 +222,12 @@ class ArgparseFunctor:
if action.option_strings:
cmd_str[0] += '{} '.format(action.option_strings[0])
+ is_remainder_arg = action.dest == self._remainder_arg
+
if isinstance(value, List) or isinstance(value, tuple):
for item in value:
item = str(item).strip()
- if token_resembles_flag(item, self._parser):
+ if not is_remainder_arg and is_potential_flag(item, self._parser):
raise ValueError('{} appears to be a flag and should be supplied as a keyword argument '
'to the function.'.format(item))
item = quote_string_if_needed(item)
@@ -240,7 +242,7 @@ class ArgparseFunctor:
else:
value = str(value).strip()
- if token_resembles_flag(value, self._parser):
+ if not is_remainder_arg and is_potential_flag(value, self._parser):
raise ValueError('{} appears to be a flag and should be supplied as a keyword argument '
'to the function.'.format(value))
value = quote_string_if_needed(value)