@@ -201,21 +201,6 @@ def _run(self):
201201 # reconstruct the cmd2 command from the python call
202202 cmd_str = ['' ]
203203
204- def has_optional_prefix (arg : str ) -> bool :
205- """
206- Checks if an argument value begins with prefix characters intended for argparse optional values
207- Allows anything that appears to be a negative number
208- :param arg: argument value being checked
209- :return: True if arg begins with one of the prefix characters
210- """
211- if self ._parser ._negative_number_matcher .match (arg ):
212- return False
213-
214- for char in self ._parser .prefix_chars :
215- if arg .startswith (char ):
216- return True
217- return False
218-
219204 def process_argument (action , value ):
220205 if isinstance (action , argparse ._CountAction ):
221206 if isinstance (value , int ):
@@ -240,7 +225,7 @@ def process_argument(action, value):
240225 if isinstance (value , List ) or isinstance (value , tuple ):
241226 for item in value :
242227 item = str (item ).strip ()
243- if has_optional_prefix (item ):
228+ if self . _parser . _parse_optional (item ) is not None :
244229 raise ValueError ('Value provided for {} ({}) appears to be an optional' .
245230 format (action .dest , item ))
246231 item = quote_string_if_needed (item )
@@ -255,7 +240,7 @@ def process_argument(action, value):
255240
256241 else :
257242 value = str (value ).strip ()
258- if has_optional_prefix (value ):
243+ if self . _parser . _parse_optional (value ) is not None :
259244 raise ValueError ('Value provided for {} ({}) appears to be an optional' .format (action .dest , value ))
260245 value = quote_string_if_needed (value )
261246 cmd_str [0 ] += '{} ' .format (value )
0 commit comments