diff options
author | 2011-01-23 16:55:11 +0000 | |
---|---|---|
committer | 2011-01-23 16:55:11 +0000 | |
commit | 9699603819c7514657fe4713892f84ef35d02e4c (patch) | |
tree | 74712c2de04e8f5c498e3e294d7718d5d0274e6d /src/lib/util/options.c | |
parent | 01158b20fe52b66826ba93de224d3bc3c9a93d1e (diff) |
- Display suggestions in case commands that require game name are called and there were no matching games [Miodrag Milanovic]
- Display suggestions for driver even if there are additional parameters that do not match (used on MESS where we have driver dependent parameters)
Diffstat (limited to 'src/lib/util/options.c')
-rw-r--r-- | src/lib/util/options.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/lib/util/options.c b/src/lib/util/options.c index 29a8a026a4d..b618b36e04c 100644 --- a/src/lib/util/options.c +++ b/src/lib/util/options.c @@ -456,11 +456,32 @@ int options_set_option_callback(core_options *opts, const char *name, void (*cal of command line arguments -------------------------------------------------*/ -int options_parse_command_line(core_options *opts, int argc, char **argv, int priority) +int options_parse_command_line(core_options *opts, int argc, char **argv, int priority, int show_error) { int unadorned_index = 0; int arg; + for (arg = 1; arg < argc; arg++) + { + const char *optionname; + options_data *data; + int is_unadorned; + /* determine the entry name to search for */ + is_unadorned = (argv[arg][0] != '-'); + if (!is_unadorned) + optionname = &argv[arg][1]; + else + optionname = OPTION_UNADORNED(unadorned_index); + + /* find our entry */ + data = find_entry_data(opts, optionname, TRUE); + if (data == NULL) continue; + if ((data->flags & OPTION_COMMAND) != 0) { + // in case of any command force show error to TRUE + show_error = TRUE; + break; + } + } /* loop over commands, looking for options */ for (arg = 1; arg < argc; arg++) { @@ -479,6 +500,7 @@ int options_parse_command_line(core_options *opts, int argc, char **argv, int pr data = find_entry_data(opts, optionname, TRUE); if (data == NULL) { + if (!show_error) continue; message(opts, OPTMSG_ERROR, "Error: unknown option: %s\n", argv[arg]); return 1; } |