Open igorcoding opened 6 years ago
igorcoding, there is mutex(...) method for your use-case.
How does it solve my use case? My goal is to call parse multiple times, for example
./my_program --template=basic --basic_option1=value1
--template
to argparseparse_known_args
to parse only arguments we defined and ignore others (because right now parse() fails if encounters unknown args)template
argument we add additional arguments to argparse, using parser:option("--basic_option1", "Option 1")
This is also useful with the help messages - collect all arguments and only then display all valid options even if user specified template, i.e. ./my_program --template=basic -h
It is very useful to parse args partially, like in Python - https://docs.python.org/3/library/argparse.html#partial-parsing
Typical usecase - add additional options, depending on the value of another option.