summaryrefslogtreecommitdiff
path: root/src/support
diff options
context:
space:
mode:
Diffstat (limited to 'src/support')
-rw-r--r--src/support/command-line.cpp9
-rw-r--r--src/support/command-line.h14
2 files changed, 16 insertions, 7 deletions
diff --git a/src/support/command-line.cpp b/src/support/command-line.cpp
index 0e638173e..1b9f64295 100644
--- a/src/support/command-line.cpp
+++ b/src/support/command-line.cpp
@@ -136,11 +136,13 @@ void Options::parse(int argc, const char* argv[]) {
// Positional.
switch (positional) {
case Arguments::Zero:
+ // Optional arguments must use --flag=A format, and not separated by
+ // spaces (which would be ambiguous).
+ case Arguments::Optional:
std::cerr << "Unexpected positional argument '" << currentOption
<< "'\n";
exit(EXIT_FAILURE);
case Arguments::One:
- case Arguments::Optional:
if (positionalsSeen) {
std::cerr << "Unexpected second positional argument '"
<< currentOption << "' for " << positionalName << '\n';
@@ -198,11 +200,6 @@ void Options::parse(int argc, const char* argv[]) {
}
break;
case Arguments::Optional:
- if (!argument.size()) {
- if (i + 1 != e) {
- argument = argv[++i];
- }
- }
break;
}
option->action(this, argument);
diff --git a/src/support/command-line.h b/src/support/command-line.h
index 53bdbff28..99d98eec9 100644
--- a/src/support/command-line.h
+++ b/src/support/command-line.h
@@ -34,7 +34,19 @@ namespace wasm {
class Options {
public:
using Action = std::function<void(Options*, const std::string&)>;
- enum class Arguments { Zero, One, N, Optional };
+
+ enum class Arguments {
+ // No arguments.
+ Zero,
+ // One argument, in the form --flag A or --flag=A
+ One,
+ // Multiple arguments, in the form --flag A B C
+ N,
+ // An optional single argument, in the form --flag=A (we disallow --flag A
+ // as that would be ambiguous regarding whether A is another flag, or an
+ // argument to us).
+ Optional
+ };
bool debug;
std::map<std::string, std::string> extra;