Add Tap#contents
methods.
This commit is contained in:
parent
7671606ddc
commit
785750ee63
@ -62,13 +62,11 @@ module Homebrew
|
||||
if tap.installed?
|
||||
info += tap.pinned? ? "pinned" : "unpinned"
|
||||
info += ", private" if tap.private?
|
||||
if (formula_count = tap.formula_files.size).positive?
|
||||
info += ", #{Formatter.pluralize(formula_count, "formula")}"
|
||||
if (contents = tap.contents).empty?
|
||||
info += ", no commands/casks/formulae"
|
||||
else
|
||||
info += ", #{contents.join(", ")}"
|
||||
end
|
||||
if (command_count = tap.command_files.size).positive?
|
||||
info += ", #{Formatter.pluralize(command_count, "command")}"
|
||||
end
|
||||
info += ", no formulae/commands" if (formula_count + command_count).zero?
|
||||
info += "\n#{tap.path} (#{tap.path.abv})"
|
||||
info += "\nFrom: #{tap.remote.nil? ? "N/A" : tap.remote}"
|
||||
else
|
||||
|
@ -284,9 +284,8 @@ class Tap
|
||||
|
||||
link_completions_and_manpages
|
||||
|
||||
casks = Formatter.pluralize(cask_files.count, "cask")
|
||||
formulae = Formatter.pluralize(formula_files.count, "formula")
|
||||
puts "Tapped #{formulae} and #{casks} (#{path.abv})." unless quiet
|
||||
formatted_contents = Formatter.enumeration(*contents)&.prepend(" ")
|
||||
puts "Tapped#{formatted_contents} (#{path.abv})." unless quiet
|
||||
Descriptions.cache_formulae(formula_names)
|
||||
|
||||
return if options[:clone_target]
|
||||
@ -315,8 +314,7 @@ class Tap
|
||||
puts "Untapping #{name}..."
|
||||
|
||||
abv = path.abv
|
||||
casks = Formatter.pluralize(cask_files.count, "cask")
|
||||
formulae = Formatter.pluralize(formula_files.count, "formula")
|
||||
formatted_contents = Formatter.enumeration(*contents)&.prepend(" ")
|
||||
|
||||
unpin if pinned?
|
||||
Descriptions.uncache_formulae(formula_names)
|
||||
@ -324,7 +322,7 @@ class Tap
|
||||
Utils::Link.unlink_completions(path)
|
||||
path.rmtree
|
||||
path.parent.rmdir_if_possible
|
||||
puts "Untapped #{formulae} and #{casks} (#{abv})."
|
||||
puts "Untapped#{formatted_contents} (#{abv})."
|
||||
clear_cache
|
||||
end
|
||||
|
||||
@ -348,6 +346,24 @@ class Tap
|
||||
@cask_dir ||= path/"Casks"
|
||||
end
|
||||
|
||||
def contents
|
||||
contents = []
|
||||
|
||||
if (command_count = command_files.count).positive?
|
||||
contents << Formatter.pluralize(command_count, "command")
|
||||
end
|
||||
|
||||
if (cask_count = cask_files.count).positive?
|
||||
contents << Formatter.pluralize(cask_count, "cask")
|
||||
end
|
||||
|
||||
if (formula_count = formula_files.count).positive?
|
||||
contents << Formatter.pluralize(formula_count, "formula")
|
||||
end
|
||||
|
||||
contents
|
||||
end
|
||||
|
||||
# an array of all {Formula} files of this {Tap}.
|
||||
def formula_files
|
||||
@formula_files ||= if formula_dir.directory?
|
||||
@ -432,7 +448,8 @@ class Tap
|
||||
|
||||
# an array of all commands files of this {Tap}.
|
||||
def command_files
|
||||
@command_files ||= Pathname.glob("#{path}/cmd/brew-*").select(&:executable?)
|
||||
@command_files ||= Pathname.glob("#{path}/cmd/brew{,cask}-*")
|
||||
.select { |file| file.executable? || file.extname == ".rb" }
|
||||
end
|
||||
|
||||
# path to the pin record for this {Tap}.
|
||||
|
Loading…
x
Reference in New Issue
Block a user