aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/bdep.cxx14
-rw-r--r--bdep/sync.cxx29
2 files changed, 30 insertions, 13 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.
}
diff --git a/bdep/sync.cxx b/bdep/sync.cxx
index ea76b17..d03f18a 100644
--- a/bdep/sync.cxx
+++ b/bdep/sync.cxx
@@ -4,7 +4,7 @@
#include <bdep/sync.hxx>
#include <list>
-#include <cstring> // strchr()
+#include <cstring> // strchr(), strcmp()
#include <libbpkg/manifest.hxx>
@@ -1305,6 +1305,12 @@ namespace bdep
{
while (gs.more ())
{
+ // Stop (rather than fail) on unknown option to handle
+ // -@<cfg-name>.
+ //
+ if (po.parse (gs, cli::unknown_mode::stop) && !gs.more ())
+ break;
+
const char* a (gs.peek ());
// Handle @<cfg-name> & -@<cfg-name>.
@@ -1316,15 +1322,24 @@ namespace bdep
if (n.empty ())
fail << "missing configuration name in '" << a << "'";
- po.config_name ().emplace_back (move (n), gs.position ());
+ po.config_name ().emplace_back (move (n));
po.config_name_specified (true);
gs.next ();
- continue;
}
+ //
+ // Handle unknown option and argument.
+ //
+ else
+ {
+ // Don't report '-' and '--' as unknown options and let bpkg
+ // deal with arguments other than configuration variables.
+ //
+ if (a[0] == '-' && a[1] != '\0' && strcmp (a, "--") != 0)
+ throw cli::unknown_option (a);
- if (!po.parse (gs))
- break;
+ args.push_back (gs.next ());
+ }
}
}
catch (const cli::exception& e)
@@ -1440,10 +1455,6 @@ namespace bdep
}
}
- // Add the rest of group arguments (e.g., configuration variables).
- //
- for (; gs.more (); args.push_back (gs.next ())) ;
-
args.push_back ("}+");
}