I have an argument parser with subcommands, however some subcommand parameters are shared across all subcommands (i.e. number of threads to use). Currently, I have pass the shared param like this:
python program.py --threads 10 subcommand --flag1 --flag2
but That seems unnatural and I'd like to support something like
python program.py subcommand --flag1 --flag2 --threads 10
The C++ CLI11 parsing library supports this with "fallthrough" options, where a flag that doesn't match to the subcommand falls through to the main command. Is there any way to do this with argparse other than duplicating the flag for every subcommand?