Error out for unrecognized option, more than one file
Change-Id: I7b7797a04ce824f263c4db6e64eefee083cc4c9d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24340
Reviewed-by: dan sinclair <dsinclair@google.com>
diff --git a/samples/main.cc b/samples/main.cc
index fcafe07..f16548b 100644
--- a/samples/main.cc
+++ b/samples/main.cc
@@ -162,6 +162,16 @@
} else if (arg == "--dump-ast") {
opts->dump_ast = true;
} else if (!arg.empty()) {
+ if (arg[0] == '-') {
+ std::cerr << "Unrecognized option: " << arg << std::endl;
+ return false;
+ }
+ if (!opts->input_filename.empty()) {
+ std::cerr << "More than one input file specified: '"
+ << opts->input_filename << "' and '" << arg << "'"
+ << std::endl;
+ return false;
+ }
opts->input_filename = arg;
}
}