aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorAndrew Janke2016-05-11 09:19:45 -0700
committerAndrew Janke2016-05-11 09:19:45 -0700
commit63ea9295cf726bfccea39ffc308b80ea5c23fed9 (patch)
treefadedb825b243c4be19b34231d3233e7fbabcd7e /Library/Homebrew
parent5f06312916e8ae518e8a9f212f7e683c49ceee67 (diff)
downloadbrew-63ea9295cf726bfccea39ffc308b80ea5c23fed9.tar.bz2
brew audit: add --display-filename format option for easy grepping (#221)
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/cmd/audit.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb
index a307a8349..70b5b13ac 100644
--- a/Library/Homebrew/cmd/audit.rb
+++ b/Library/Homebrew/cmd/audit.rb
@@ -1,4 +1,4 @@
-#: * `audit` [`--strict`] [`--online`] [`--display-cop-names`] [<formulae>]:
+#: * `audit` [`--strict`] [`--online`] [`--display-cop-names`] [`--display-filename`] [<formulae>]:
#: Check <formulae> for Homebrew coding style violations. This should be
#: run before submitting a new formula.
#:
@@ -13,6 +13,9 @@
#: If `--display-cop-names` is passed, the RuboCop cop name for each violation
#: is included in the output.
#:
+#: If `--display-filename` is passed, every line of output is prefixed with the
+#: name of the file or formula being audited, to make the output easy to grep.
+#:
#: `audit` exits with a non-zero status if any errors are found. This is useful,
#: for instance, for implementing pre-commit hooks.
@@ -69,8 +72,12 @@ module Homebrew
formula_count += 1
problem_count += fa.problems.size
- problem_lines = fa.problems.map { |p| " * #{p.chomp.gsub("\n", "\n ")}" }
- puts "#{f.full_name}:", problem_lines
+ problem_lines = fa.problems.map { |p| "* #{p.chomp.gsub("\n", "\n ")}" }
+ if ARGV.include? "--display-filename"
+ puts problem_lines.map { |s| "#{f.path}: #{s}"}
+ else
+ puts "#{f.full_name}:", problem_lines.map { |s| " #{s}"}
+ end
end
unless problem_count.zero?