diff --git a/include/mgba/feature/commandline.h b/include/mgba/feature/commandline.h index 17af655fe..9ce118fd2 100644 --- a/include/mgba/feature/commandline.h +++ b/include/mgba/feature/commandline.h @@ -44,6 +44,7 @@ struct mSubParser { bool (*parse)(struct mSubParser* parser, int option, const char* arg); bool (*parseLong)(struct mSubParser* parser, const char* option, const char* arg); void (*apply)(struct mSubParser* parser, struct mCoreConfig* config); + bool (*handleExtraArg)(struct mSubParser* parser, const char* arg); const char* extraOptions; const struct mOption* longOptions; void* opts; diff --git a/src/feature/commandline.c b/src/feature/commandline.c index fca5c7747..1e22a4f2c 100644 --- a/src/feature/commandline.c +++ b/src/feature/commandline.c @@ -187,7 +187,21 @@ bool mArgumentsParse(struct mArguments* args, int argc, char* const* argv, struc argc -= optind; argv += optind; if (argc > 1) { - return false; + for (j = 0; j < argc; ++j) { + bool handled = false; + for (i = 0; i < nSubparsers; ++i) { + if (!subparsers[i].handleExtraArg) { + continue; + } + handled = subparsers[i].handleExtraArg(&subparsers[i], argv[j]); + if (handled) { + break; + } + } + if (!handled) { + return false; + } + } } else if (argc == 1) { args->fname = strdup(argv[0]); } else { @@ -303,6 +317,7 @@ void mSubParserGraphicsInit(struct mSubParser* parser, struct mGraphicsOpts* opt parser->apply = _applyGraphicsArgs; parser->extraOptions = GRAPHICS_OPTIONS; parser->longOptions = _graphicsLongOpts; + parser->handleExtraArg = NULL; opts->multiplier = 0; opts->fullscreen = false; }