util/OptionParser: collect remaining arguments

Allow the caller to use a simple "for" loop without checking
arguments.
This commit is contained in:
Max Kellermann
2018-01-16 11:03:04 +01:00
parent 0066f7a818
commit 68f660dbcc
3 changed files with 13 additions and 10 deletions

View File

@@ -357,11 +357,9 @@ ParseCommandLine(int argc, char **argv, struct options *options)
// Second pass: find non-option parameters (i.e. config file)
const char *config_file = nullptr;
for (int i = 1; i < argc; ++i) {
if (OptionParser::IsOption(argv[i]))
continue;
for (const char *i : parser.GetRemaining()) {
if (config_file == nullptr) {
config_file = argv[i];
config_file = i;
continue;
}