From 9351245e161c6c494c78a4088f312cb6b7645bd5 Mon Sep 17 00:00:00 2001 From: Eric Lin Date: Fri, 27 Apr 2018 10:07:01 -0400 Subject: small tweak. saving state. --- cmd2/pyscript_bridge.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'cmd2/pyscript_bridge.py') diff --git a/cmd2/pyscript_bridge.py b/cmd2/pyscript_bridge.py index 88e12bfb..d48317c3 100644 --- a/cmd2/pyscript_bridge.py +++ b/cmd2/pyscript_bridge.py @@ -64,15 +64,16 @@ class ArgparseFunctor: for action in parser._actions: # was something provided for the argument if action.dest in self._args: - # was the argument a flag? - # TODO: Handle 'narg' and 'append' options - if action.option_strings: - cmd_str[0] += '"{}" "{}" '.format(action.option_strings[0], self._args[action.dest]) + if isinstance(action, argparse._SubParsersAction): + traverse_parser(action.choices[self._args[action.dest]]) else: + # was the argument a flag? + if action.option_strings: + cmd_str[0] += '{} '.format(action.option_strings[0]) + + # TODO: Handle 'narg' and 'append' options cmd_str[0] += '"{}" '.format(self._args[action.dest]) - if isinstance(action, argparse._SubParsersAction): - traverse_parser(action.choices[self._args[action.dest]]) traverse_parser(self._parser) func(cmd_str[0]) -- cgit v1.2.1