Package: argpass
argpassAn argparse extension to collect and pass on command line arguments (potentially starting with hyphens) to other programs.TL;DR:Imagine writing a wrapper script that calls two or more other programs. In many cases, you will want to collect command line arguments for these programs and pass them on unaltered. Usingargparse, this is not possible. Withargpass, simply passnargs=argpass.NargsOption.COLLECT_UNTIL_NEXT_KNOWNtoparser.add_argumentand it will collect all strings (regardless of format) until the next known argument.InstallationInstall withpip install argpassMotivationBuilt-inargparselacks an option to ignore unrecognized flag strings (usually starting with-or--), which makes it difficult to collect arguments and pass them on to other programs in some cases. It can be done withArgumentParser.parse_known_args(seedocs) which collects all unrecognized arguments, but this only works when just one other program is invoked from our script. Collecting arguments starting with dashes to pass on to more than one program is impossible with argparse, which as caused quite somefrustration.An exampleConsider the following example: We have a Python script that takes an input file, a regular argument, and other arguments that should be passed on to another program which is invoked from within our script. We would call our script as follows:python script.py --file example.txt --regular-arg exampleArg --args-to-pass-on --param1 val1 --param2 val2Thanks toArgumentParser.parse_known_args, this case can be handled byargparsejust fine:$catscript.pyimportargparseparser=argparse.ArgumentParser()parser.add_argument("--file")parser.add_argument("--regular-arg")parser.add_argument("--args-to-pass-on",nargs="*")args,unknown=parser.parse_known_args()args.args_to_pass_on=unknownprint(args)$pythonscript.py--fileexample.txt--regular-argexampleArg--args-to-pass-on--param1val1--param2val2Namespace(file='example.txt',regular_arg='exampleArg',args_to_pass_on=['--param1','val1','--param2','val2'])However, this approach only works when we want to collect arguments for just a single program. Doing something likepython script.py \
    --file example.txt --regular-arg exampleArg \
    --args-to-pass-on-1 --param1 val1 --param2 val2 \
    --args-to-pass-on-2 bla --param3 val3 --blucannot be achieved with argparse.argpassis a thin wrapper around argparse that allows you to do exactly that. When adding another paramater to the parser, simply specifynargs=NargsOption.COLLECT_UNTIL_NEXT_KNOWNandargpasswill collect all strings until the next known argument:$catscript.pyimportargpassparser=argpass.ArgumentParser()parser.add_argument("--file")parser.add_argument("--regular-arg")parser.add_argument("--args-to-pass-on-1",nargs=argpass.NargsOption.COLLECT_UNTIL_NEXT_KNOWN)parser.add_argument("--args-to-pass-on-2",nargs=argpass.NargsOption.COLLECT_UNTIL_NEXT_KNOWN)print(parser.parse_args())$pythonscript.py\--fileexample.txt--regular-argexampleArg\--args-to-pass-on-1--param1val1--param2val2\--args-to-pass-on-2bla--param3val3--bluNamespace(file='example.txt',regular_arg='exampleArg',args_to_pass_on_1=['--param1','val1','--param2','val2'],args_to_pass_on_2=['bla','--param3','val3','--blu'])