update: highlight installed formulae in report
Closes Homebrew/homebrew#44335. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
f47f5088fb
commit
0114a26483
@ -425,10 +425,33 @@ class Report
|
|||||||
|
|
||||||
def dump_formula_report(key, title)
|
def dump_formula_report(key, title)
|
||||||
formula = select_formula(key)
|
formula = select_formula(key)
|
||||||
formula.map! { |oldname, newname| "#{oldname} -> #{newname}" } if key == :R
|
|
||||||
unless formula.empty?
|
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
|
ohai title
|
||||||
puts_columns formula
|
puts_columns(formula, formula_installed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def installed?(formula)
|
||||||
|
(HOMEBREW_CELLAR/formula.split("/").last).directory?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user