Message262318
Is this the kind of scenario that you have problems with?
parser = argparse.ArgumentParser()
sp = parser.add_subparsers(dest='cmd')
p1 = sp.add_parser('cmd1')
p1.add_argument('-f')
p2 = sp.add_parser('cmd2')
p2.add_argument('-b')
p3 = sp.add_parser('cmd3', parents=[p1,p2],add_help=False, conflict_handler='resolve')
p3.add_argument('-c')
The problem is, apparently, that 'resolve' removes the '-h' option_string from the 1st subparser (but does not delete the whole action). A kludgy fix is to add the '-h' back in (after p3 is created):
p1._actions[0].option_strings=['-h']
'p1._actions' is the list of actions (arguments) for subparser p1. Usually help is the first action (if isn't in p3 because of the parents resolve action).
I may work out a custom conflict handler function, but for now this appears to solve the issue. I don't know if the patch I proposed solves your issue or not. |
|
Date |
User |
Action |
Args |
2016-03-24 01:57:09 | paul.j3 | set | recipients:
+ paul.j3, bethard, docs@python, deckar01 |
2016-03-24 01:57:08 | paul.j3 | set | messageid: <1458784628.89.0.137151208464.issue22401@psf.upfronthosting.co.za> |
2016-03-24 01:57:08 | paul.j3 | link | issue22401 messages |
2016-03-24 01:57:07 | paul.j3 | create | |
|