Hint about --fix/--apply when running without them

Change-Id: Ib2b5270734cad3739b0d09bc41cba8236a6a6964
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/25660
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Commit-Queue: Matt Stark <msta@google.com>
diff --git a/examples/simple_build/hello_shared.cc b/examples/simple_build/hello_shared.cc
index 58be84c..d777cbe 100644
--- a/examples/simple_build/hello_shared.cc
+++ b/examples/simple_build/hello_shared.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include "hello_shared.h"
+#include "hello_static.h"
 
 const char* GetSharedText() {
   return "world";
diff --git a/src/gn/command_check.cc b/src/gn/command_check.cc
index 45331bf..0edfc2f 100644
--- a/src/gn/command_check.cc
+++ b/src/gn/command_check.cc
@@ -299,6 +299,7 @@
 
   bool remaining_violations = false;
   bool needs_separator = false;
+  bool has_suggestions = false;
   for (auto& violation : violations) {
     if (needs_separator) {
       OutputString("___________________\n", DECORATION_YELLOW);
@@ -316,6 +317,9 @@
           },
           apply, setup);
       fixed = apply && (exit_code == SuggestResult::kSuccess);
+      if (!buf.empty()) {
+        has_suggestions = true;
+      }
     }
 
     auto& err = violation.error;
@@ -348,6 +352,11 @@
     }
   }
 
+  if (!apply && has_suggestions) {
+    OutputString("\nTo automatically apply suggestions, add --fix.\n",
+                 DECORATION_DIM);
+  }
+
   return !remaining_violations;
 }
 
diff --git a/src/gn/command_suggest.cc b/src/gn/command_suggest.cc
index e88dffa..0005dc5 100644
--- a/src/gn/command_suggest.cc
+++ b/src/gn/command_suggest.cc
@@ -920,6 +920,7 @@
       setup->builder().GetAllResolvedTargets();
 
   SuggestResult exit_status = SuggestResult::kSuccess;
+  bool has_suggestions = false;
   for (size_t i = 1; i < args.size(); i++) {
     if (i != 1) {
       OutputString("\n");
@@ -947,7 +948,8 @@
     SuggestResult res = OutputSuggestions(
         all_targets, &setup->build_settings(),
         setup->loader()->default_toolchain_label(), includer, included,
-        [](std::string_view str, TextDecoration dec, HtmlEscaping esc) {
+        [&](std::string_view str, TextDecoration dec, HtmlEscaping esc) {
+          has_suggestions = true;
           ::OutputString(str, dec, esc);
         },
         apply, setup);
@@ -959,6 +961,11 @@
     }
   }
 
+  if (!apply && has_suggestions && exit_status != SuggestResult::kFailure) {
+    OutputString("\nTo automatically apply suggestions, add --apply.\n",
+                 DECORATION_DIM);
+  }
+
   return static_cast<int>(exit_status);
 }