aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/cask.rb2
-rw-r--r--Library/Homebrew/cmd/deps.rb7
-rw-r--r--Library/Homebrew/cmd/help.rb42
-rw-r--r--Library/Homebrew/cmd/info.rb12
-rw-r--r--Library/Homebrew/cmd/install.rb52
-rw-r--r--Library/Homebrew/cmd/link.rb4
-rw-r--r--Library/Homebrew/cmd/list.rb2
-rw-r--r--Library/Homebrew/cmd/search.rb4
-rw-r--r--Library/Homebrew/cmd/style.rb17
-rw-r--r--Library/Homebrew/cmd/switch.rb4
-rw-r--r--Library/Homebrew/cmd/uninstall.rb6
-rw-r--r--Library/Homebrew/cmd/unpack.rb2
-rw-r--r--Library/Homebrew/cmd/uses.rb4
-rw-r--r--Library/Homebrew/cmd/vendor-install.sh17
14 files changed, 107 insertions, 68 deletions
diff --git a/Library/Homebrew/cmd/cask.rb b/Library/Homebrew/cmd/cask.rb
index 8a68b8d9a..550081d46 100644
--- a/Library/Homebrew/cmd/cask.rb
+++ b/Library/Homebrew/cmd/cask.rb
@@ -5,6 +5,6 @@ module Homebrew
module_function
def cask
- Hbc::CLI.process(ARGV)
+ Hbc::CLI.run(*ARGV)
end
end
diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb
index f80bdfb0d..bbf0c1b0b 100644
--- a/Library/Homebrew/cmd/deps.rb
+++ b/Library/Homebrew/cmd/deps.rb
@@ -38,6 +38,7 @@
#: `--include-optional`, and `--skip-recommended` as documented above.
# encoding: UTF-8
+
require "formula"
require "ostruct"
@@ -112,10 +113,10 @@ module Homebrew
end
else
deps = f.deps.reject do |dep|
- ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) }
+ ignores.any? { |ignore| dep.send(ignore) } && includes.none? { |include| dep.send(include) }
end
reqs = f.requirements.reject do |req|
- ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) }
+ ignores.any? { |ignore| req.send(ignore) } && includes.none? { |include| req.send(include) }
end
end
@@ -160,7 +161,7 @@ module Homebrew
else
"├──"
end
- prefix_ext = i == max ? " " : "│ "
+ prefix_ext = (i == max) ? " " : "│ "
puts prefix + "#{chr} #{dep_display_name(dep)}"
recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_ext)
end
diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb
index 1378e7b1f..fc3878f16 100644
--- a/Library/Homebrew/cmd/help.rb
+++ b/Library/Homebrew/cmd/help.rb
@@ -1,27 +1,27 @@
-HOMEBREW_HELP = <<-EOS.freeze
-Example usage:
- brew search [TEXT|/REGEX/]
- brew (info|home|options) [FORMULA...]
- brew install FORMULA...
- brew update
- brew upgrade [FORMULA...]
- brew uninstall FORMULA...
- brew list [FORMULA...]
+HOMEBREW_HELP = <<-EOS.unindent.freeze
+ Example usage:
+ brew search [TEXT|/REGEX/]
+ brew (info|home|options) [FORMULA...]
+ brew install FORMULA...
+ brew update
+ brew upgrade [FORMULA...]
+ brew uninstall FORMULA...
+ brew list [FORMULA...]
-Troubleshooting:
- brew config
- brew doctor
- brew install -vd FORMULA
+ Troubleshooting:
+ brew config
+ brew doctor
+ brew install -vd FORMULA
-Developers:
- brew create [URL [--no-fetch]]
- brew edit [FORMULA...]
- http://docs.brew.sh/Formula-Cookbook.html
+ Developers:
+ brew create [URL [--no-fetch]]
+ brew edit [FORMULA...]
+ http://docs.brew.sh/Formula-Cookbook.html
-Further help:
- man brew
- brew help [COMMAND]
- brew home
+ Further help:
+ man brew
+ brew help [COMMAND]
+ brew home
EOS
# NOTE Keep the lenth of vanilla --help less than 25 lines!
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index e7ad6821d..826f31bbd 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -123,8 +123,16 @@ module Homebrew
puts f.desc if f.desc
puts Formatter.url(f.homepage) if f.homepage
- conflicts = f.conflicts.map(&:name).sort!
- puts "Conflicts with: #{conflicts*", "}" unless conflicts.empty?
+ conflicts = f.conflicts.map do |c|
+ reason = " (because #{c.reason})" if c.reason
+ "#{c.name}#{reason}"
+ end.sort!
+ unless conflicts.empty?
+ puts <<-EOS.undent
+ Conflicts with:
+ #{conflicts.join("\n ")}
+ EOS
+ end
kegs = f.installed_kegs.sort_by(&:version)
if kegs.empty?
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 08d1ffccf..423b47884 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -95,9 +95,8 @@ module Homebrew
args << "--verbose" if ARGV.verbose?
ARGV.casks.each do |c|
- cmd = "brew", "cask", "install", c, *args
- ohai cmd.join " "
- system(*cmd)
+ ohai "brew cask install #{c} #{args.join " "}"
+ system("#{HOMEBREW_PREFIX}/bin/brew", "cask", "install", c, *args)
end
end
@@ -146,8 +145,17 @@ module Homebrew
# linked to opt, because installing without any warnings can break
# dependencies. Therefore before performing other checks we need to be
# sure --force flag is passed.
- opoo "#{f.full_name} is a keg-only and another version is linked to opt."
- puts "Use `brew install --force` if you want to install this version"
+ if f.outdated?
+ optlinked_version = Keg.for(f.opt_prefix).version
+ onoe <<-EOS.undent
+ #{f.full_name} #{optlinked_version} is already installed
+ To upgrade to #{f.version}, run `brew upgrade #{f.name}`
+ EOS
+ else
+ opoo <<-EOS.undent
+ #{f.full_name} #{f.pkg_version} is already installed
+ EOS
+ end
elsif (ARGV.build_head? && new_head_installed) || prefix_installed
# After we're sure that --force flag is passed for linked to opt
# keg-only we need to be sure that the version we're attempting to
@@ -159,30 +167,38 @@ module Homebrew
f.pkg_version
end
- msg = "#{f.full_name}-#{installed_version} already installed"
+ msg = "#{f.full_name} #{installed_version} is already installed"
linked_not_equals_installed = f.linked_version != installed_version
if f.linked? && linked_not_equals_installed
- msg << ", however linked version is #{f.linked_version}"
- opoo msg
- puts "You can use `brew switch #{f} #{installed_version}` to link this version."
+ msg = <<-EOS.undent
+ #{msg}
+ The currently linked version is #{f.linked_version}
+ You can use `brew switch #{f} #{installed_version}` to link this version.
+ EOS
elsif !f.linked? || f.keg_only?
- msg << ", it's just not linked."
- opoo msg
- else
- opoo msg
+ msg = <<-EOS.undent
+ #{msg}, it's just not linked.
+ You can use `brew link #{f}` to link this version.
+ EOS
end
+ opoo msg
elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first
- msg = "#{old_formula.full_name}-#{old_formula.installed_version} already installed"
+ msg = "#{old_formula.full_name} #{old_formula.installed_version} already installed"
if !old_formula.linked? && !old_formula.keg_only?
- msg << ", it's just not linked."
+ msg = <<-EOS.undent
+ #{msg}, it's just not linked.
+ You can use `brew link #{old_formula.full_name}` to link this version.
+ EOS
end
opoo msg
elsif f.migration_needed? && !ARGV.force?
# Check if the formula we try to install is the same as installed
# but not migrated one. If --force passed then install anyway.
- opoo "#{f.oldname} already installed, it's just not migrated"
- puts "You can migrate formula with `brew migrate #{f}`"
- puts "Or you can force install it with `brew install #{f} --force`"
+ opoo <<-EOS.undent
+ #{f.oldname} already installed, it's just not migrated
+ You can migrate formula with `brew migrate #{f}`
+ Or you can force install it with `brew install #{f} --force`
+ EOS
else
# If none of the above is true and the formula is linked, then
# FormulaInstaller will handle this case.
diff --git a/Library/Homebrew/cmd/link.rb b/Library/Homebrew/cmd/link.rb
index b8bd135e0..6c4b912e8 100644
--- a/Library/Homebrew/cmd/link.rb
+++ b/Library/Homebrew/cmd/link.rb
@@ -72,9 +72,7 @@ module Homebrew
puts "#{n} symlinks created"
end
- if keg_only && !ARGV.homebrew_developer?
- puts_keg_only_path_message(keg)
- end
+ puts_keg_only_path_message(keg) if keg_only && !ARGV.homebrew_developer?
end
end
end
diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb
index 790d858aa..f5c4e68ac 100644
--- a/Library/Homebrew/cmd/list.rb
+++ b/Library/Homebrew/cmd/list.rb
@@ -129,7 +129,7 @@ module Homebrew
names.each do |d|
versions = d.subdirs.map { |pn| pn.basename.to_s }
next if ARGV.include?("--multiple") && versions.length < 2
- puts "#{d.basename} #{versions*" "}"
+ puts "#{d.basename} #{versions * " "}"
end
end
end
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index f71a14ba1..2b35dfc36 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -107,14 +107,14 @@ module Homebrew
dirname, filename = File.split(match["path"])
next unless valid_dirnames.include?(dirname)
tap = Tap.fetch(match["repository"]["full_name"])
- next if tap.installed?
+ next if tap.installed? && match["repository"]["owner"]["login"] != "caskroom"
"#{tap.name}/#{File.basename(filename, ".rb")}"
end.compact
end
def search_formulae(regex)
aliases = Formula.alias_full_names
- results = (Formula.full_names+aliases).grep(regex).sort
+ results = (Formula.full_names + aliases).grep(regex).sort
results.map do |name|
begin
diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb
index cf41d91ee..7da71749c 100644
--- a/Library/Homebrew/cmd/style.rb
+++ b/Library/Homebrew/cmd/style.rb
@@ -19,6 +19,7 @@
require "utils"
require "json"
+require "open3"
module Homebrew
module_function
@@ -72,7 +73,11 @@ module Homebrew
args = %w[
--force-exclusion
]
- args << "--auto-correct" if fix
+ if fix
+ args << "--auto-correct"
+ else
+ args << "--parallel"
+ end
if options[:except_cops]
options[:except_cops].map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") }
@@ -94,26 +99,28 @@ module Homebrew
if files.nil?
args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml"
- args += [HOMEBREW_LIBRARY_PATH]
+ args << HOMEBREW_LIBRARY_PATH
else
args << "--config" << HOMEBREW_LIBRARY/".rubocop.yml"
args += files
end
+ cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" }
+
case output_type
when :print
args << "--display-cop-names" if ARGV.include? "--display-cop-names"
args << "--format" << "simple" if files
- system "rubocop", *args
+ system(cache_env, "rubocop", *args)
!$?.success?
when :json
- json = Utils.popen_read_text("rubocop", "--format", "json", *args)
+ json, _, status = Open3.capture3(cache_env, "rubocop", "--format", "json", *args)
# exit status of 1 just means violations were found; other numbers mean
# execution errors.
# exitstatus can also be nil if RuboCop process crashes, e.g. due to
# native extension problems.
# JSON needs to be at least 2 characters.
- if $?.exitstatus.nil? || $?.exitstatus > 1 || json.to_s.length < 2
+ if !(0..1).cover?(status.exitstatus) || json.to_s.length < 2
raise "Error running `rubocop --format json #{args.join " "}`"
end
RubocopResults.new(JSON.parse(json))
diff --git a/Library/Homebrew/cmd/switch.rb b/Library/Homebrew/cmd/switch.rb
index 6eed1fd96..a40b4d88e 100644
--- a/Library/Homebrew/cmd/switch.rb
+++ b/Library/Homebrew/cmd/switch.rb
@@ -25,7 +25,7 @@ module Homebrew
end
# Does the target version exist?
- unless (rack+version).directory?
+ unless (rack/version).directory?
onoe "#{name} does not have a version \"#{version}\" in the Cellar."
versions = rack.subdirs.map { |d| Keg.new(d).version }
@@ -41,7 +41,7 @@ module Homebrew
keg.unlink
end
- keg = Keg.new(rack+version)
+ keg = Keg.new(rack/version)
# Link new version, if not keg-only
if keg_only?(rack)
diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb
index 9c51a0d1c..4839ba1e0 100644
--- a/Library/Homebrew/cmd/uninstall.rb
+++ b/Library/Homebrew/cmd/uninstall.rb
@@ -55,7 +55,7 @@ module Homebrew
if rack.directory?
versions = rack.subdirs.map(&:basename)
- verb = versions.length == 1 ? "is" : "are"
+ verb = Formatter.pluralize(versions.length, "is", "are")
puts "#{keg.name} #{versions.join(", ")} #{verb} still installed."
puts "Remove all versions with `brew uninstall --force #{keg.name}`."
end
@@ -109,11 +109,11 @@ module Homebrew
protected
def are(items)
- items.count == 1 ? "is" : "are"
+ Formatter.pluralize(items.count, "is", "are", show_count: false)
end
def they(items)
- items.count == 1 ? "it" : "they"
+ Formatter.pluralize(items.count, "it", "they", show_count: false)
end
def list(items)
diff --git a/Library/Homebrew/cmd/unpack.rb b/Library/Homebrew/cmd/unpack.rb
index 89992e1f0..51c2b59f0 100644
--- a/Library/Homebrew/cmd/unpack.rb
+++ b/Library/Homebrew/cmd/unpack.rb
@@ -29,7 +29,7 @@ module Homebrew
raise "Cannot write to #{unpack_dir}" unless unpack_dir.writable_real?
formulae.each do |f|
- stage_dir = unpack_dir.join("#{f.name}-#{f.version}")
+ stage_dir = unpack_dir/"#{f.name}-#{f.version}"
if stage_dir.exist?
raise "Destination #{stage_dir} already exists!" unless ARGV.force?
diff --git a/Library/Homebrew/cmd/uses.rb b/Library/Homebrew/cmd/uses.rb
index bab174184..24684c3b6 100644
--- a/Library/Homebrew/cmd/uses.rb
+++ b/Library/Homebrew/cmd/uses.rb
@@ -98,10 +98,10 @@ module Homebrew
reqs = reqs_by_formula.map(&:last)
else
deps = f.deps.reject do |dep|
- ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) }
+ ignores.any? { |ignore| dep.send(ignore) } && includes.none? { |include| dep.send(include) }
end
reqs = f.requirements.reject do |req|
- ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) }
+ ignores.any? { |ignore| req.send(ignore) } && includes.none? { |include| req.send(include) }
end
end
next true if deps.any? do |dep|
diff --git a/Library/Homebrew/cmd/vendor-install.sh b/Library/Homebrew/cmd/vendor-install.sh
index 8f08e49fb..fe7e26dd4 100644
--- a/Library/Homebrew/cmd/vendor-install.sh
+++ b/Library/Homebrew/cmd/vendor-install.sh
@@ -39,10 +39,10 @@ fetch() {
if [[ -n "$HOMEBREW_QUIET" ]]
then
- curl_args+=(--silent)
+ curl_args[${#curl_args[*]}]="--silent"
elif [[ -z "$HOMEBREW_VERBOSE" ]]
then
- curl_args+=(--progress-bar)
+ curl_args[${#curl_args[*]}]="--progress-bar"
fi
temporary_path="$CACHED_LOCATION.incomplete"
@@ -76,12 +76,21 @@ fetch() {
trap - SIGINT
fi
- if [[ -n "$(which shasum)" ]]
+ if [[ -x "$(which shasum)" ]]
then
sha="$(shasum -a 256 "$CACHED_LOCATION" | cut -d' ' -f1)"
- elif [[ -n "$(which sha256sum)" ]]
+ elif [[ -x "$(which sha256sum)" ]]
then
sha="$(sha256sum "$CACHED_LOCATION" | cut -d' ' -f1)"
+ elif [[ -x "$(which ruby)" ]]
+ then
+ sha="$(ruby <<EOSCRIPT
+ require 'digest/sha2'
+ digest = Digest::SHA256.new
+ File.open('$CACHED_LOCATION', 'rb') { |f| digest.update(f.read) }
+ puts digest.hexdigest
+EOSCRIPT
+)"
else
odie "Cannot verify the checksum ('shasum' or 'sha256sum' not found)!"
fi