diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-19 10:14:42 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-19 10:14:42 +0200 |
commit | 7d82192a5d9e87b14625ba3aff2413e09da827be (patch) | |
tree | 8ec77c4b20d0c8a2a23101d85a7851e51b9f5ad0 | |
parent | 06161c2ba7e3d032268e9483a04b46a00b8c86db (diff) |
Fix bug in option passing between driver and plugin
This requires new option description functionality from CLI.
-rw-r--r-- | odb/makefile | 1 | ||||
-rw-r--r-- | odb/odb.cxx | 22 |
2 files changed, 17 insertions, 6 deletions
diff --git a/odb/makefile b/odb/makefile index ac11dca..0724ec6 100644 --- a/odb/makefile +++ b/odb/makefile @@ -118,6 +118,7 @@ $(gen): $(cli) $(gen): cli := $(cli) $(gen): cli_options += \ --generate-specifier \ +--generate-description \ --suppress-undocumented \ --generate-file-scanner \ --include-with-brackets \ diff --git a/odb/odb.cxx b/odb/odb.cxx index c45f3b9..5bc6605 100644 --- a/odb/odb.cxx +++ b/odb/odb.cxx @@ -389,6 +389,7 @@ main (int argc, char* argv[]) // Encode plugin options. // + cli::options const& desc (options::description ()); for (size_t i (0); i < end; ++i) { string k, v; @@ -401,21 +402,30 @@ main (int argc, char* argv[]) continue; } - if (a.size () > 2) + cli::options::const_iterator it (desc.find (a)); + + if (it == desc.end ()) + { + e << argv[0] << ": ice: unexpected option '" << a << "'" << endl; + return 1; + } + + if (a.size () > 2 && a[0] == '-' && a[1] == '-') k = string (a, 2); // long format else k = string (a, 1); // short format // If there are more arguments then we may have a value. // - if (i + 1 < end) + if (!it->flag ()) { - a = plugin_args[i + 1]; - if (!(a.size () > 1 && a[0] == '-')) + if (i + 1 == end) { - v = a; - ++i; + e << argv[0] << ": ice: expected argument for '" << a << "'" << endl; + return 1; } + + v = plugin_args[++i]; } args.push_back (encode_plugin_option (k, v)); |