Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Unified Diff: mojo/shell/desktop/mojo_main.cc

Issue 731923002: Emit error if unknown switch is passed to mojo_shell (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Remove static Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/shell/switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/desktop/mojo_main.cc
diff --git a/mojo/shell/desktop/mojo_main.cc b/mojo/shell/desktop/mojo_main.cc
index d929c51c495804073c8d2b51bf8e7e5a0fdcb9d6..caa84e0c6aaf4bb926579d1ce54db573b9c69c82 100644
--- a/mojo/shell/desktop/mojo_main.cc
+++ b/mojo/shell/desktop/mojo_main.cc
@@ -105,9 +105,21 @@ int main(int argc, char** argv) {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
- if (!command_line.HasSwitch(switches::kEnableExternalApplications) &&
- (command_line.HasSwitch(switches::kHelp) ||
- command_line.GetArgs().empty())) {
+
+ const std::set<std::string> all_switches = switches::GetAllSwitches();
+ const base::CommandLine::SwitchMap switches = command_line.GetSwitches();
+ bool found_unknown_switch = false;
+ for (const auto& s : switches) {
+ if (all_switches.find(s.first) == all_switches.end()) {
+ std::cerr << "unknown switch: " << s.first << std::endl;
+ found_unknown_switch = true;
+ }
+ }
+
+ if (found_unknown_switch ||
+ (!command_line.HasSwitch(switches::kEnableExternalApplications) &&
+ (command_line.HasSwitch(switches::kHelp) ||
+ command_line.GetArgs().empty()))) {
Usage();
return 0;
}
« no previous file with comments | « no previous file | mojo/shell/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698