Skip to content

Commit

Permalink
Show installations status for cask dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
HaraldNordgren committed Aug 7, 2024
1 parent 90a90b3 commit 9926315
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
Empty file modified Library/Homebrew/cmd/--env.rb
100644 → 100755
Empty file.
20 changes: 2 additions & 18 deletions Library/Homebrew/cmd/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
require "keg"
require "tab"
require "json"
require "utils/info"
require "utils/spdx"
require "deprecate_disable"
require "api"
Expand Down Expand Up @@ -320,7 +321,7 @@ def info_formula(formula)
ohai "Dependencies"
%w[build required recommended optional].map do |type|
deps = formula.deps.send(type).uniq
puts "#{type.capitalize}: #{decorate_dependencies deps}" unless deps.empty?
puts "#{type.capitalize}: #{Utils::Info.decorate_dependencies(deps)}" unless deps.empty?
end
end

Expand All @@ -345,17 +346,6 @@ def info_formula(formula)
Utils::Analytics.formula_output(formula, args:)
end

def decorate_dependencies(dependencies)
deps_status = dependencies.map do |dep|
if dep.satisfied?([])
pretty_installed(dep_display_s(dep))
else
pretty_uninstalled(dep_display_s(dep))
end
end
deps_status.join(", ")
end

def decorate_requirements(requirements)
req_status = requirements.map do |req|
req_s = req.display_s
Expand All @@ -364,12 +354,6 @@ def decorate_requirements(requirements)
req_status.join(", ")
end

def dep_display_s(dep)
return dep.name if dep.option_tags.empty?

"#{dep.name} #{dep.option_tags.map { |o| "--#{o}" }.join(" ")}"
end

def info_cask(cask)
require "cask/info"

Expand Down
24 changes: 24 additions & 0 deletions Library/Homebrew/utils/info.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# typed: true
# frozen_string_literal: true

module Utils
# Helper functions for formula and cask info.
module Info
def self.decorate_dependencies(dependencies)
deps_status = dependencies.map do |dep|
if dep.satisfied?([])

Check warning on line 9 in Library/Homebrew/utils/info.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/info.rb#L8-L9

Added lines #L8 - L9 were not covered by tests
pretty_installed(dep_display_s(dep))
else
pretty_uninstalled(dep_display_s(dep))
end
end
deps_status.join(", ")

Check warning on line 15 in Library/Homebrew/utils/info.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/info.rb#L15

Added line #L15 was not covered by tests
end

def self.dep_display_s(dep)
return dep.name if dep.option_tags.empty?

"#{dep.name} #{dep.option_tags.map { |o| "--#{o}" }.join(" ")}"

Check warning on line 21 in Library/Homebrew/utils/info.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/info.rb#L21

Added line #L21 was not covered by tests
end
end
end

0 comments on commit 9926315

Please sign in to comment.