Permalink
Browse files

Add spell checking for debug flags.

I just used `ninja -d stat` and it took me a bit to realize that I missed the
trailing 's'.

While here, move the message printing from printf() to Error(). This makes the
output consistent with other error outputs: The messages are now prefixed with
"ninja: error: " instead of just "ninja: " and they go to stderr instead of
stdout.
  • Loading branch information...
1 parent 543f3ed commit 61f4a9905a7e68149a5420617f23d4e73783335c @nico nico committed Mar 27, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/ninja.cc
View
@@ -629,7 +629,14 @@ bool DebugEnable(const string& name, Globals* globals) {
g_explaining = true;
return true;
} else {
- printf("ninja: unknown debug setting '%s'\n", name.c_str());
+ const char* suggestion =
+ SpellcheckString(name, "stats", "explain", NULL);
+ if (suggestion) {
+ Error("unknown debug setting '%s', did you mean '%s'?",
+ name.c_str(), suggestion);
+ } else {
+ Error("unknown debug setting '%s'", name.c_str());
+ }
return false;
}
}

0 comments on commit 61f4a99

Please sign in to comment.