pluralize formulae in tap/untap

Closes Homebrew/homebrew#28560.
This commit is contained in:
Adam Vandenberg 2014-05-26 11:19:00 -07:00
parent 6eb220d78f
commit 8d44db6b40
4 changed files with 10 additions and 12 deletions

View File

@ -27,7 +27,7 @@ module Homebrew extend self
files = [] files = []
tapd.find_formula { |file| files << file } tapd.find_formula { |file| files << file }
link_tap_formula(files) link_tap_formula(files)
puts "Tapped #{files.length} formula" puts "Tapped #{files.length} formula#{plural(files.length, 'e')}"
if private_tap?(repouser, repo) then puts <<-EOS.undent if private_tap?(repouser, repo) then puts <<-EOS.undent
It looks like you tapped a private repository. To avoid entering your It looks like you tapped a private repository. To avoid entering your
@ -77,7 +77,7 @@ module Homebrew extend self
count += 1 count += 1
end end
end end
puts "Pruned #{count} dead formula" puts "Pruned #{count} dead formula#{plural(count, 'e')}"
return unless HOMEBREW_REPOSITORY.join("Library/Taps").exist? return unless HOMEBREW_REPOSITORY.join("Library/Taps").exist?
@ -89,7 +89,7 @@ module Homebrew extend self
count += link_tap_formula(files) count += link_tap_formula(files)
end end
puts "Tapped #{count} formula" puts "Tapped #{count} formula#{plural(count, 'e')}"
end end
private private

View File

@ -22,7 +22,7 @@ module Homebrew extend self
unlink_tap_formula(files) unlink_tap_formula(files)
tapd.rmtree tapd.rmtree
tapd.dirname.rmdir_if_possible tapd.dirname.rmdir_if_possible
puts "Untapped #{files.length} formula" puts "Untapped #{files.length} formula#{plural(files.length, 'e')}"
end end
def unlink_tap_formula paths def unlink_tap_formula paths

View File

@ -1,12 +1,6 @@
require 'cmd/install' require 'cmd/install'
require 'cmd/outdated' require 'cmd/outdated'
class Fixnum
def plural_s
if self != 1 then "s" else "" end
end
end
module Homebrew extend self module Homebrew extend self
def upgrade def upgrade
Homebrew.perform_preinstall_checks Homebrew.perform_preinstall_checks
@ -35,14 +29,14 @@ module Homebrew extend self
end end
unless outdated.empty? unless outdated.empty?
oh1 "Upgrading #{outdated.length} outdated package#{outdated.length.plural_s}, with result:" oh1 "Upgrading #{outdated.length} outdated package#{plural(outdated.length)}, with result:"
puts outdated.map{ |f| "#{f.name} #{f.pkg_version}" } * ", " puts outdated.map{ |f| "#{f.name} #{f.pkg_version}" } * ", "
else else
oh1 "No packages to upgrade" oh1 "No packages to upgrade"
end end
unless upgrade_pinned? || pinned.empty? unless upgrade_pinned? || pinned.empty?
oh1 "Not upgrading #{pinned.length} pinned package#{pinned.length.plural_s}:" oh1 "Not upgrading #{pinned.length} pinned package#{plural(pinned.length)}:"
puts pinned.map{ |f| "#{f.name} #{f.pkg_version}" } * ", " puts pinned.map{ |f| "#{f.name} #{f.pkg_version}" } * ", "
end end

View File

@ -78,6 +78,10 @@ def pretty_duration s
return "%.1f minutes" % (s/60) return "%.1f minutes" % (s/60)
end end
def plural n, s="s"
(n == 1) ? "" : s
end
def interactive_shell f=nil def interactive_shell f=nil
unless f.nil? unless f.nil?
ENV['HOMEBREW_DEBUG_PREFIX'] = f.prefix ENV['HOMEBREW_DEBUG_PREFIX'] = f.prefix