--- argparse-orig.py 2010-12-12 17:31:45.000000000 -0800 +++ argparse.py 2010-12-12 17:43:50.000000000 -0800 @@ -1023,9 +1023,12 @@ class _ChoicesPseudoAction(Action): - def __init__(self, name, help): + def __init__(self, name, aliases, help): + dest = name + if aliases: + dest += ' (%s)' % ','.join(aliases) sup = super(_SubParsersAction._ChoicesPseudoAction, self) - sup.__init__(option_strings=[], dest=name, help=help) + sup.__init__(option_strings=[], dest=dest, help=help) def __init__(self, option_strings, @@ -1053,15 +1056,25 @@ if kwargs.get('prog') is None: kwargs['prog'] = '%s %s' % (self._prog_prefix, name) + if 'aliases' in kwargs: + aliases = kwargs.pop('aliases') + else: + aliases = () + # create a pseudo-action to hold the choice help if 'help' in kwargs: help = kwargs.pop('help') - choice_action = self._ChoicesPseudoAction(name, help) + choice_action = self._ChoicesPseudoAction(name, aliases, help) self._choices_actions.append(choice_action) # create the parser and add it to the map parser = self._parser_class(**kwargs) self._name_parser_map[name] = parser + + # make parser available under aliases also + for alias in aliases: + self._name_parser_map[alias] = parser + return parser def _get_subactions(self):