diff --git a/argparse.c b/argparse.c index 3521f534c..5568cd30a 100644 --- a/argparse.c +++ b/argparse.c @@ -233,6 +233,9 @@ argparse_parse(struct argparse *self, int argc, const char **argv) if (self->flags & ARGPARSE_STOP_AT_NON_OPTION) { goto end; } + if (self->flags & ARGPARSE_NON_OPTION_IS_INVALID) { + goto unknown; + } // if it's not option or is a single char '-', copy verbatim self->out[self->cpidx++] = self->argv[0]; continue; diff --git a/argparse.h b/argparse.h index 44ce835a0..1efc06052 100644 --- a/argparse.h +++ b/argparse.h @@ -23,6 +23,7 @@ typedef int argparse_callback (struct argparse *self, enum argparse_flag { ARGPARSE_STOP_AT_NON_OPTION = 1, + ARGPARSE_NON_OPTION_IS_INVALID = 2, }; enum argparse_option_type {