I think my problem is very similar to this question, but it's not exact, and unfortunately I haven't been able to extrapolate my solution.
I have some arguments that I only want to use if another argument is set to 'False'. Otherwise, these arguments should not be required, and, in fact, should not be provided.
Presently, my code basically looks like this:
if __name__ == '__main__':
parser = argparse.ArgumentParser()
#Arguments that will always be mandatory
#str2bool is a function I have to detect T/F, which I've verified works
parser.add_argument('--null_variants_provided', type=str2bool, nargs='?',
help='Are you providing a list of null variants?
If not, more arguments will be required',
required=True)
args = parser.parse_args()
#Options that will sometimes be necessary
if args.null_variants_provided is False:
parser.add_argument('--LCR_regions_file',
help='I need to be required if
above argument is False', required=True)
args = parser.parse_args()
The reason the solution I linked to won't work for me, I suspect, is it's simply checking if a particular argument was passed- it's not checking what that argument is. The reason my solution above does not work, I suspect, is because once I set args the first time, the code checks which arguments have been passed, and if there are any extra arguments (namely, arguments that I define later), it throws an error.
Can you guys think of a way to do this?