Message131262
| Author |
John.Didion |
| Recipients |
John.Didion |
| Date |
2011年03月17日.15:51:29 |
| SpamBayes Score |
4.915817e-08 |
| Marked as misclassified |
No |
| Message-id |
<1300377092.03.0.159307937388.issue11588@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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)) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年03月17日 15:51:32 | John.Didion | set | recipients:
+ John.Didion |
| 2011年03月17日 15:51:32 | John.Didion | set | messageid: <1300377092.03.0.159307937388.issue11588@psf.upfronthosting.co.za> |
| 2011年03月17日 15:51:29 | John.Didion | link | issue11588 messages |
| 2011年03月17日 15:51:29 | John.Didion | create |
|