tap-info: tweak output for two edge cases

Improve output in the (rare) cases where a tap offers both commands and
formulae or neither. Also adjust code to stay below the 80 column limit.

Closes Homebrew/homebrew#44995.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Martin Afanasjew 2015-09-21 14:16:11 +02:00 committed by Mike McQuaid
parent 7044bf7bbf
commit e4de6907fd

View File

@ -42,11 +42,14 @@ module Homebrew
puts unless i == 0
info = "#{tap}: "
if tap.installed?
info += tap.pinned? ? "pinned, " : "unpinned, "
formula_count = tap.formula_files.size
info += "#{formula_count} formula#{plural(formula_count, "e")} " if formula_count > 0
command_count = tap.command_files.size
info += "#{command_count} command#{plural(command_count)} " if command_count > 0
info += tap.pinned? ? "pinned" : "unpinned"
if (formula_count = tap.formula_files.size) > 0
info += ", #{formula_count} formula#{plural(formula_count, "e")}"
end
if (command_count = tap.command_files.size) > 0
info += ", #{command_count} command#{plural(command_count)}"
end
info += ", no formulae/commands" if formula_count + command_count == 0
info += "\n#{tap.path} (#{tap.path.abv})"
info += "\nFrom: #{tap.remote.nil? ? "N/A" : tap.remote}"
else