diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-09-20 21:05:04 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-09-22 17:41:12 +0300 |
commit | 7cf3492e05e304fa4fdb17763a2bec9363dfcef5 (patch) | |
tree | f83db215283d70a91fef3a0869fc381727733356 /bdep/bdep.cxx | |
parent | aeaa89ac75ac83e3953817de74bb901260b6ac81 (diff) |
Allow options and arguments in any order inside argument groups in sync
Also optimize options/arguments parsing in bdep.cxx.
Diffstat (limited to 'bdep/bdep.cxx')
-rw-r--r-- | bdep/bdep.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/bdep/bdep.cxx b/bdep/bdep.cxx index 3e762e8..7bc747d 100644 --- a/bdep/bdep.cxx +++ b/bdep/bdep.cxx @@ -181,6 +181,12 @@ init (const common_options& co, { if (opt) { + // Parse the next chunk of options until we reach an argument (or eos). + // Stop (rather than fail) on unknown option to handle -@<cfg-name>. + // + if (o.parse (scan, cli::unknown_mode::stop) && !scan.more ()) + break; + const char* a (scan.peek ()); // If we see first "--", then we are done parsing options. @@ -194,7 +200,7 @@ init (const common_options& co, continue; } - // @<cfg-name> & -@<cfg-name> + // Handle @<cfg-name> & -@<cfg-name> // if (*a == '@' || (*a == '-' && a[1] == '@')) { @@ -203,10 +209,10 @@ init (const common_options& co, continue; } - // Parse the next chunk of options until we reach an argument (or eos). + // Handle unknown option. // - if (o.parse (scan)) - continue; + if (a[0] == '-' && a[1] != '\0') + throw cli::unknown_option (a); // Fall through. } |