Author John.Didion
Recipients John.Didion
Date 2011-03-17.15:51:29
SpamBayes Score 4.91582e-08
Marked as misclassified No
Message-id <>
Just as some options are mutually exclusive, there are others that are "necessarily inclusive," i.e. all or nothing. I propose the addition of ArgumentParser.add_necessarily_inclusive_group(required=True).

This also means that argparse will need to support nested groups. For example, if I want to set up options such that the user has to provide an output file OR (an output directory AND (an output file pattern OR an output file extension)):

output_group = parser.add_mutually_exclusive_group(required=True)
output_group.add_argument("-o", "--outfile")
outdir_group = output_group.add_necessarily_inclusive_group()
outdir_group.add_argument("-O", "--outdir")
outfile_group = outdir_group.add_mutually_exclusive_group(required=True)
outfile_group.add_argument("-p", "--outpattern")
outfile_group.add_argument("-s", "--outsuffix")

The usage should then look like:

(-o FILE | (-O DIR & (-p PATTERN | -s SUFFIX))
Date User Action Args
2011-03-17 15:51:32John.Didionsetrecipients: + John.Didion
2011-03-17 15:51:32John.Didionsetmessageid: <>
2011-03-17 15:51:29John.Didionlinkissue11588 messages
2011-03-17 15:51:29John.Didioncreate