diff options
| author | Andrew Janke | 2016-05-11 09:19:45 -0700 |
|---|---|---|
| committer | Andrew Janke | 2016-05-11 09:19:45 -0700 |
| commit | 63ea9295cf726bfccea39ffc308b80ea5c23fed9 (patch) | |
| tree | fadedb825b243c4be19b34231d3233e7fbabcd7e | |
| parent | 5f06312916e8ae518e8a9f212f7e683c49ceee67 (diff) | |
| download | brew-63ea9295cf726bfccea39ffc308b80ea5c23fed9.tar.bz2 | |
brew audit: add --display-filename format option for easy grepping (#221)
| -rw-r--r-- | Library/Homebrew/cmd/audit.rb | 13 | ||||
| -rw-r--r-- | share/doc/homebrew/brew.1.html | 5 | ||||
| -rw-r--r-- | share/man/man1/brew.1 | 5 |
3 files changed, 18 insertions, 5 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? diff --git a/share/doc/homebrew/brew.1.html b/share/doc/homebrew/brew.1.html index 6322abf16..8c18f9c0a 100644 --- a/share/doc/homebrew/brew.1.html +++ b/share/doc/homebrew/brew.1.html @@ -39,7 +39,7 @@ If no search term is given, all locally available formulae are listed.</p></dd> Read more at <a href="https://git.io/brew-analytics" data-bare-link="true">https://git.io/brew-analytics</a>.</p></dd> <dt><code>analytics</code> (<code>on</code>|<code>off</code>)</dt><dd><p>Turn on/off Homebrew's analytics.</p></dd> <dt><code>analytics</code> <code>regenerate-uuid</code></dt><dd><p>Regenerate UUID used in Homebrew's analytics.</p></dd> -<dt><code>audit</code> [<code>--strict</code>] [<code>--online</code>] [<code>--display-cop-names</code>] [<var>formulae</var>]</dt><dd><p>Check <var>formulae</var> for Homebrew coding style violations. This should be +<dt><code>audit</code> [<code>--strict</code>] [<code>--online</code>] [<code>--display-cop-names</code>] [<code>--display-filename</code>] [<var>formulae</var>]</dt><dd><p>Check <var>formulae</var> for Homebrew coding style violations. This should be run before submitting a new formula.</p> <p>If no <var>formulae</var> are provided, all of them are checked.</p> @@ -53,6 +53,9 @@ connection are run. This should be used when creating for new formulae.</p> <p>If <code>--display-cop-names</code> is passed, the RuboCop cop name for each violation is included in the output.</p> +<p>If <code>--display-filename</code> 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.</p> + <p><code>audit</code> exits with a non-zero status if any errors are found. This is useful, for instance, for implementing pre-commit hooks.</p></dd> <dt><code>cat</code> <var>formula</var></dt><dd><p>Display the source to <var>formula</var>.</p></dd> diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1 index 99514666f..bb3839263 100644 --- a/share/man/man1/brew.1 +++ b/share/man/man1/brew.1 @@ -56,7 +56,7 @@ Turn on/off Homebrew\'s analytics\. Regenerate UUID used in Homebrew\'s analytics\. . .TP -\fBaudit\fR [\fB\-\-strict\fR] [\fB\-\-online\fR] [\fB\-\-display\-cop\-names\fR] [\fIformulae\fR] +\fBaudit\fR [\fB\-\-strict\fR] [\fB\-\-online\fR] [\fB\-\-display\-cop\-names\fR] [\fB\-\-display\-filename\fR] [\fIformulae\fR] Check \fIformulae\fR for Homebrew coding style violations\. This should be run before submitting a new formula\. . .IP @@ -72,6 +72,9 @@ If \fB\-\-online\fR is passed, additional slower checks that require a network c If \fB\-\-display\-cop\-names\fR is passed, the RuboCop cop name for each violation is included in the output\. . .IP +If \fB\-\-display\-filename\fR 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\. +. +.IP \fBaudit\fR exits with a non\-zero status if any errors are found\. This is useful, for instance, for implementing pre\-commit hooks\. . .TP |
