lebrice / SimpleParsing

Simple, Elegant, Typed Argument Parsing with argparse
MIT License
386 stars 47 forks source link

Ignore unrecognized arguments #216

Closed timbmg closed 1 year ago

timbmg commented 1 year ago

Is there some way to ignore unrecognized/unknown arguments? In argparse there is this option:

from argparse import ArgumentParser
parser = ArgumentParser()

args, unknown = parser.parse_known_args()

My use case I am running a couple of python scripts in sequence using taskfile, i.e. with a single command. However, they require different arguments. Taskfile has the option to pass all cli arguments on to tasks, however for this to work, I would basically need to ignore all args that are not defined for that script.

timbmg commented 1 year ago

Found it.

options, leftover_args = simple_parsing.parse_known_args(Options)