Bug 1192315 - Support remainder arguments from predefined parsers in mach, r=gps

Mach has special handling for remainder arguments which previously
only worked with the decoration form. Extend this to also work when
a command passes in an explict parser

--HG--
extra : commitid : ICnYk764Xbc
extra : rebase_source : 1518edcb7bef375cbc2931b8da54b015045c8ce1
This commit is contained in:
James Graham 2015-08-07 18:13:05 +01:00
parent b1576e7399
commit 399b0b18f5

View File

@ -180,14 +180,20 @@ class CommandAction(argparse.Action):
'usage': usage,
}
remainder = None
if handler.parser:
subparser = handler.parser
subparser.context = self._context
for arg in subparser._actions[:]:
if arg.nargs == argparse.REMAINDER:
subparser._actions.remove(arg)
remainder = (arg.dest,), {'default': arg.default,
'nargs': arg.nargs,
'help': arg.help}
else:
subparser = argparse.ArgumentParser(**parser_args)
remainder = None
for arg in handler.arguments:
# Remove our group keyword; it's not needed here.
group_name = arg[1].get('group')