Skip to content

Commit

Permalink
Don't always inactivate actions just because they ate some arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
kislyuk committed Nov 27, 2012
1 parent d5fea70 commit 0279e77
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions argcomplete/my_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ def consume_optional(start_index):
selected_patterns = arg_strings_pattern[start:]
self.active_actions = [action] # Added by argcomplete
arg_count = match_argument(action, selected_patterns)
if arg_count > 0: # Added by argcomplete
self.active_actions = [] # Added by argcomplete
stop = start + arg_count
args = arg_strings[start:stop]
action_tuples.append((action, args, option_string))
Expand All @@ -164,12 +162,13 @@ def consume_positionals(start_index):
# slice off the appropriate arg strings for each Positional
# and add the Positional and its args to the list
for action, arg_count in zip(positionals, arg_counts):
self.active_actions.append(action) # Added by argcomplete
if arg_count > 0: # Added by argcomplete
self.active_actions = [action] # Added by argcomplete
else: # Added by argcomplete
self.active_actions.append(action) # Added by argcomplete
args = arg_strings[start_index: start_index + arg_count]
start_index += arg_count
take_action(action, args)
if arg_count > 0: # Added by argcomplete
self.active_actions = [] # Added by argcomplete

# slice off the Positionals that we just parsed and return the
# index at which the Positionals' string args stopped
Expand Down

0 comments on commit 0279e77

Please sign in to comment.