Skip to content
Snippets Groups Projects
Commit 0114a264 authored by Martin Afanasjew's avatar Martin Afanasjew Committed by Mike McQuaid
Browse files

update: highlight installed formulae in report


Closes Homebrew/homebrew#44335.

Signed-off-by: default avatarMike McQuaid <mike@mikemcquaid.com>
parent f47f5088
No related branches found
No related tags found
No related merge requests found
......@@ -425,10 +425,33 @@ class Report
def dump_formula_report(key, title)
formula = select_formula(key)
formula.map! { |oldname, newname| "#{oldname} -> #{newname}" } if key == :R
unless formula.empty?
# Determine list item indices of installed formulae.
formula_installed_index = formula.each_index.select do |index|
name, newname = formula[index]
installed?(name) || (newname && installed?(newname))
end
# Format list items of renamed formulae.
if key == :R
formula.map! { |oldname, newname| "#{oldname} -> #{newname}" }
end
# Append suffix '(installed)' to list items of installed formulae.
formula_installed_index.each do |index|
formula[index] += " (installed)"
end
# Fetch list items of installed formulae for highlighting.
formula_installed = formula.values_at(*formula_installed_index)
# Dump formula list.
ohai title
puts_columns formula
puts_columns(formula, formula_installed)
end
end
def installed?(formula)
(HOMEBREW_CELLAR/formula.split("/").last).directory?
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment