Merge pull request #4357 from reitermarkus/tapped-cask-count
Show tapped casks.
This commit is contained in:
commit
cbc3184436
@ -62,13 +62,11 @@ module Homebrew
|
|||||||
if tap.installed?
|
if tap.installed?
|
||||||
info += tap.pinned? ? "pinned" : "unpinned"
|
info += tap.pinned? ? "pinned" : "unpinned"
|
||||||
info += ", private" if tap.private?
|
info += ", private" if tap.private?
|
||||||
if (formula_count = tap.formula_files.size).positive?
|
info += if (contents = tap.contents).empty?
|
||||||
info += ", #{Formatter.pluralize(formula_count, "formula")}"
|
", no commands/casks/formulae"
|
||||||
|
else
|
||||||
|
", #{contents.join(", ")}"
|
||||||
end
|
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 += "\n#{tap.path} (#{tap.path.abv})"
|
||||||
info += "\nFrom: #{tap.remote.nil? ? "N/A" : tap.remote}"
|
info += "\nFrom: #{tap.remote.nil? ? "N/A" : tap.remote}"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -284,8 +284,8 @@ class Tap
|
|||||||
|
|
||||||
link_completions_and_manpages
|
link_completions_and_manpages
|
||||||
|
|
||||||
formula_count = formula_files.size
|
formatted_contents = Formatter.comma_and(*contents)&.prepend(" ")
|
||||||
puts "Tapped #{Formatter.pluralize(formula_count, "formula")} (#{path.abv})" unless quiet
|
puts "Tapped#{formatted_contents} (#{path.abv})." unless quiet
|
||||||
Descriptions.cache_formulae(formula_names)
|
Descriptions.cache_formulae(formula_names)
|
||||||
|
|
||||||
return if options[:clone_target]
|
return if options[:clone_target]
|
||||||
@ -311,15 +311,18 @@ class Tap
|
|||||||
require "descriptions"
|
require "descriptions"
|
||||||
raise TapUnavailableError, name unless installed?
|
raise TapUnavailableError, name unless installed?
|
||||||
|
|
||||||
puts "Untapping #{name}... (#{path.abv})"
|
puts "Untapping #{name}..."
|
||||||
|
|
||||||
|
abv = path.abv
|
||||||
|
formatted_contents = Formatter.comma_and(*contents)&.prepend(" ")
|
||||||
|
|
||||||
unpin if pinned?
|
unpin if pinned?
|
||||||
formula_count = formula_files.size
|
|
||||||
Descriptions.uncache_formulae(formula_names)
|
Descriptions.uncache_formulae(formula_names)
|
||||||
Utils::Link.unlink_manpages(path)
|
Utils::Link.unlink_manpages(path)
|
||||||
Utils::Link.unlink_completions(path)
|
Utils::Link.unlink_completions(path)
|
||||||
path.rmtree
|
path.rmtree
|
||||||
path.parent.rmdir_if_possible
|
path.parent.rmdir_if_possible
|
||||||
puts "Untapped #{Formatter.pluralize(formula_count, "formula")}"
|
puts "Untapped#{formatted_contents} (#{abv})."
|
||||||
clear_cache
|
clear_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -343,6 +346,24 @@ class Tap
|
|||||||
@cask_dir ||= path/"Casks"
|
@cask_dir ||= path/"Casks"
|
||||||
end
|
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}.
|
# an array of all {Formula} files of this {Tap}.
|
||||||
def formula_files
|
def formula_files
|
||||||
@formula_files ||= if formula_dir.directory?
|
@formula_files ||= if formula_dir.directory?
|
||||||
@ -427,7 +448,8 @@ class Tap
|
|||||||
|
|
||||||
# an array of all commands files of this {Tap}.
|
# an array of all commands files of this {Tap}.
|
||||||
def command_files
|
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
|
end
|
||||||
|
|
||||||
# path to the pin record for this {Tap}.
|
# path to the pin record for this {Tap}.
|
||||||
|
|||||||
@ -76,4 +76,22 @@ describe Formatter do
|
|||||||
expect(described_class.pluralize(2, "new formula")).to eq("2 new formulae")
|
expect(described_class.pluralize(2, "new formula")).to eq("2 new formulae")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "::comma_and" do
|
||||||
|
it "returns nil if given no arguments" do
|
||||||
|
expect(described_class.comma_and).to be nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns the input as string if there is only one argument" do
|
||||||
|
expect(described_class.comma_and(1)).to eq("1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "concatenates two items with “and”" do
|
||||||
|
expect(described_class.comma_and(1, 2)).to eq("1 and 2")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "concatenates all items with a comma and appends the last with “and”" do
|
||||||
|
expect(described_class.comma_and(1, 2, 3)).to eq("1, 2 and 3")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -108,4 +108,14 @@ module Formatter
|
|||||||
|
|
||||||
show_count ? "#{count} #{words}" : words
|
show_count ? "#{count} #{words}" : words
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def comma_and(*items)
|
||||||
|
# TODO: Remove when RuboCop 0.57.3 is released.
|
||||||
|
# False positive has been fixed and merged, but is not yet in a
|
||||||
|
# stable release: https://github.com/rubocop-hq/rubocop/pull/6038
|
||||||
|
*items, last = items.map(&:to_s) # rubocop:disable Lint/ShadowedArgument
|
||||||
|
return last if items.empty?
|
||||||
|
|
||||||
|
"#{items.join(", ")} and #{last}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user