Add the IsNullary(arg) and IsUnary(arg, next_arg) functions
to detect whether arg is a valid startup option.

--
MOS_MIGRATED_REVID=137512954
diff --git a/src/main/cpp/startup_options.cc b/src/main/cpp/startup_options.cc
index 06b941d..6efeccc 100644
--- a/src/main/cpp/startup_options.cc
+++ b/src/main/cpp/startup_options.cc
@@ -65,10 +65,41 @@
       output_root, "_" + product_name_lower + "_" + GetUserName());
   // 3 hours (but only 15 seconds if used within a test)
   max_idle_secs = testing ? 15 : (3 * 3600);
+  nullary_options = {"deep_execroot", "block_for_lock",
+      "host_jvm_debug", "master_blazerc", "master_bazelrc", "batch",
+      "batch_cpu_scheduling", "allow_configurable_attributes",
+      "fatal_event_bus_exceptions", "experimental_oom_more_eagerly",
+      "write_command_log", "watchfs"};
+  unary_options = {"output_base", "install_base",
+      "output_user_root", "host_jvm_profile", "host_javabase",
+      "host_jvm_args", "bazelrc", "blazerc", "io_nice_level",
+      "max_idle_secs", "experimental_oom_more_eagerly_threshold",
+      "command_port", "invocation_policy"};
 }
 
 StartupOptions::~StartupOptions() {}
 
+bool StartupOptions::IsNullary(const string &arg) const {
+  for (string option : nullary_options) {
+    if (GetNullaryOption(arg.c_str(), ("--" + option).c_str()) ||
+        GetNullaryOption(arg.c_str(), ("--no" + option).c_str())) {
+      return true;
+    }
+  }
+  return false;
+}
+
+bool StartupOptions::IsUnary(const string &arg,
+                             const string &next_arg) const {
+  for (string option : unary_options) {
+    if (GetUnaryOption(arg.c_str(), next_arg.c_str(),
+                       ("--" + option).c_str()) != NULL) {
+      return true;
+    }
+  }
+  return false;
+}
+
 void StartupOptions::AddExtraOptions(vector<string> *result) const {}
 
 blaze_exit_code::ExitCode StartupOptions::ProcessArg(
diff --git a/src/main/cpp/startup_options.h b/src/main/cpp/startup_options.h
index 7754dad..3a90b50 100644
--- a/src/main/cpp/startup_options.h
+++ b/src/main/cpp/startup_options.h
@@ -116,6 +116,15 @@
       const std::string &host_javabase, std::vector<std::string> *result,
       const std::vector<std::string> &user_options, std::string *error) const;
 
+  // Checks whether the argument is a valid nullary option.
+  // E.g. --master_bazelrc, --nomaster_bazelrc.
+  bool IsNullary(const std::string &arg) const;
+
+  // Checks whether the argument is a valid unary option.
+  // E.g. --blazerc=foo, --blazerc foo.
+  bool IsUnary(const std::string &arg,
+               const std::string &next_arg) const;
+
   // The capitalized name of this binary.
   const std::string product_name;
 
@@ -207,6 +216,12 @@
   // capitalized version of the name, as in "Bazel".
   explicit StartupOptions(const std::string &product_name);
 
+  // Holds the valid nullary startup options.
+  std::vector<std::string> nullary_options;
+
+  // Holds the valid unary startup options.
+  std::vector<std::string> unary_options;
+
  private:
   std::string host_javabase;
 };