From 61f4a9905a7e68149a5420617f23d4e73783335c Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 27 Mar 2013 16:03:52 -0700 Subject: 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. --- src/ninja.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ninja.cc b/src/ninja.cc index b24ac33..69646e1 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -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; } } -- cgit v0.12