Skip to content
This repository
Browse code

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...
commit 61f4a9905a7e68149a5420617f23d4e73783335c 1 parent 543f3ed
Nico Weber nico authored

Showing 1 changed file with 8 additions and 1 deletion. Show diff stats Hide diff stats

  1. +8 1 src/ninja.cc
9 src/ninja.cc
@@ -629,7 +629,14 @@ bool DebugEnable(const string& name, Globals* globals) {
629 629 g_explaining = true;
630 630 return true;
631 631 } else {
632   - printf("ninja: unknown debug setting '%s'\n", name.c_str());
  632 + const char* suggestion =
  633 + SpellcheckString(name, "stats", "explain", NULL);
  634 + if (suggestion) {
  635 + Error("unknown debug setting '%s', did you mean '%s'?",
  636 + name.c_str(), suggestion);
  637 + } else {
  638 + Error("unknown debug setting '%s'", name.c_str());
  639 + }
633 640 return false;
634 641 }
635 642 }

0 comments on commit 61f4a99

Please sign in to comment.
Something went wrong with that request. Please try again.