Make "gn format" honor the global -q switch
Bug: none
Change-Id: I710e6385a79d0e3f8aa586db99df60bc9cbd3072
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/5840
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
diff --git a/tools/gn/command_format.cc b/tools/gn/command_format.cc
index 5b9580b..4249c2f 100644
--- a/tools/gn/command_format.cc
+++ b/tools/gn/command_format.cc
@@ -21,6 +21,7 @@
#include "tools/gn/scheduler.h"
#include "tools/gn/setup.h"
#include "tools/gn/source_file.h"
+#include "tools/gn/switches.h"
#include "tools/gn/tokenizer.h"
namespace commands {
@@ -1168,6 +1169,9 @@
from_stdin = false;
}
+ bool quiet =
+ base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kQuiet);
+
if (from_stdin) {
if (args.size() != 0) {
Err(Location(), "Expecting no arguments when reading from stdin.\n")
@@ -1227,7 +1231,10 @@
.PrintToStdout();
return 1;
}
- printf("Wrote formatted to '%s'.\n", FilePathToUTF8(to_write).c_str());
+ if (!quiet) {
+ printf("Wrote formatted to '%s'.\n",
+ FilePathToUTF8(to_write).c_str());
+ }
}
}
}