aboutsummaryrefslogtreecommitdiff
path: root/odb/odb.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-11-19 10:14:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-11-19 10:14:42 +0200
commit7d82192a5d9e87b14625ba3aff2413e09da827be (patch)
tree8ec77c4b20d0c8a2a23101d85a7851e51b9f5ad0 /odb/odb.cxx
parent06161c2ba7e3d032268e9483a04b46a00b8c86db (diff)
Fix bug in option passing between driver and plugin
This requires new option description functionality from CLI.
Diffstat (limited to 'odb/odb.cxx')
-rw-r--r--odb/odb.cxx22
1 files changed, 16 insertions, 6 deletions
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));