Skip to content

Commit 9351245

Browse files
committed
small tweak. saving state.
1 parent 2a68a0e commit 9351245

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cmd2/pyscript_bridge.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ def traverse_parser(parser):
6464
for action in parser._actions:
6565
# was something provided for the argument
6666
if action.dest in self._args:
67-
# was the argument a flag?
68-
# TODO: Handle 'narg' and 'append' options
69-
if action.option_strings:
70-
cmd_str[0] += '"{}" "{}" '.format(action.option_strings[0], self._args[action.dest])
67+
if isinstance(action, argparse._SubParsersAction):
68+
traverse_parser(action.choices[self._args[action.dest]])
7169
else:
70+
# was the argument a flag?
71+
if action.option_strings:
72+
cmd_str[0] += '{} '.format(action.option_strings[0])
73+
74+
# TODO: Handle 'narg' and 'append' options
7275
cmd_str[0] += '"{}" '.format(self._args[action.dest])
7376

74-
if isinstance(action, argparse._SubParsersAction):
75-
traverse_parser(action.choices[self._args[action.dest]])
7677
traverse_parser(self._parser)
7778

7879
func(cmd_str[0])

0 commit comments

Comments
 (0)