Updated missing formula cask reason
- search_for_cask in missing_formula renamed to is_a_cask_reason - is_a_cask calls new getInfo method in cask/cmd/info.rb to return info string - self.info in info.rb now calls getInfo and puts return value - added ohai_title to return the ohai printout for only titles, so that ohai printout could be added to the getInfo return string without calling puts. - refactored ohai to use ohai_title - updated info_spec.rb cask info test to be more specific when matching stderr. - is_a_cask_reason will respect 'silent' - refactored print_caveats to return instead of print
This commit is contained in:
parent
648c8e4672
commit
554106d2e0
@ -12,7 +12,7 @@ module Cask
|
|||||||
|
|
||||||
def run
|
def run
|
||||||
casks.each do |cask|
|
casks.each do |cask|
|
||||||
Installer.print_caveats(cask)
|
puts Installer.print_caveats(cask)
|
||||||
ohai "Downloading external files for Cask #{cask}"
|
ohai "Downloading external files for Cask #{cask}"
|
||||||
downloaded_path = Download.new(cask, force: force?, quarantine: quarantine?).perform
|
downloaded_path = Download.new(cask, force: force?, quarantine: quarantine?).perform
|
||||||
Verify.all(cask, downloaded_path)
|
Verify.all(cask, downloaded_path)
|
||||||
|
@ -25,21 +25,25 @@ module Cask
|
|||||||
"displays information about the given Cask"
|
"displays information about the given Cask"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_info(cask)
|
||||||
|
"#{title_info(cask)}\n"\
|
||||||
|
"#{Formatter.url(cask.homepage) if cask.homepage}\n"\
|
||||||
|
"#{installation_info(cask)}\n"\
|
||||||
|
"#{repo_info(cask)}"\
|
||||||
|
"#{name_info(cask)}"\
|
||||||
|
"#{language_info(cask)}"\
|
||||||
|
"#{artifact_info(cask)}"\
|
||||||
|
"#{Installer.print_caveats(cask)}"\
|
||||||
|
end
|
||||||
|
|
||||||
def self.info(cask)
|
def self.info(cask)
|
||||||
title_info(cask)
|
puts get_info(cask)
|
||||||
puts Formatter.url(cask.homepage) if cask.homepage
|
|
||||||
installation_info(cask)
|
|
||||||
repo_info(cask)
|
|
||||||
name_info(cask)
|
|
||||||
language_info(cask)
|
|
||||||
artifact_info(cask)
|
|
||||||
Installer.print_caveats(cask)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.title_info(cask)
|
def self.title_info(cask)
|
||||||
title = "#{cask.token}: #{cask.version}"
|
title = "#{cask.token}: #{cask.version}"
|
||||||
title += " (auto_updates)" if cask.auto_updates
|
title += " (auto_updates)" if cask.auto_updates
|
||||||
puts title
|
title
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.formatted_url(url)
|
def self.formatted_url(url)
|
||||||
@ -50,27 +54,28 @@ module Cask
|
|||||||
if cask.installed?
|
if cask.installed?
|
||||||
cask.versions.each do |version|
|
cask.versions.each do |version|
|
||||||
versioned_staged_path = cask.caskroom_path.join(version)
|
versioned_staged_path = cask.caskroom_path.join(version)
|
||||||
|
message = versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist")
|
||||||
puts versioned_staged_path.to_s
|
versioned_staged_path.to_s.concat(" (").concat(message).concat(")")
|
||||||
.concat(" (")
|
|
||||||
.concat(versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist"))
|
|
||||||
.concat(")")
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "Not installed"
|
"Not installed"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.name_info(cask)
|
def self.name_info(cask)
|
||||||
ohai((cask.name.size > 1) ? "Names" : "Name")
|
<<~EOS
|
||||||
puts cask.name.empty? ? Formatter.error("None") : cask.name
|
#{ohai_title((cask.name.size > 1) ? "Names" : "Name")}
|
||||||
|
#{cask.name.empty? ? Formatter.error("None") : cask.name.join("\n")}
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.language_info(cask)
|
def self.language_info(cask)
|
||||||
return if cask.languages.empty?
|
return if cask.languages.empty?
|
||||||
|
|
||||||
ohai "Languages"
|
<<~EOS
|
||||||
puts cask.languages.join(", ")
|
#{ohai_title("Languages")}
|
||||||
|
#{cask.languages.join(", ")}
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.repo_info(cask)
|
def self.repo_info(cask)
|
||||||
@ -82,16 +87,18 @@ module Cask
|
|||||||
"#{cask.tap.default_remote}/blob/master/Casks/#{cask.token}.rb"
|
"#{cask.tap.default_remote}/blob/master/Casks/#{cask.token}.rb"
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "From: #{Formatter.url(url)}"
|
"From: #{Formatter.url(url)}\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.artifact_info(cask)
|
def self.artifact_info(cask)
|
||||||
ohai "Artifacts"
|
|
||||||
cask.artifacts.each do |artifact|
|
cask.artifacts.each do |artifact|
|
||||||
next unless artifact.respond_to?(:install_phase)
|
next unless artifact.respond_to?(:install_phase)
|
||||||
next unless DSL::ORDINARY_ARTIFACT_CLASSES.include?(artifact.class)
|
next unless DSL::ORDINARY_ARTIFACT_CLASSES.include?(artifact.class)
|
||||||
|
|
||||||
puts artifact.to_s
|
return <<~EOS
|
||||||
|
#{ohai_title("Artifacts")}
|
||||||
|
#{artifact}
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -74,7 +74,7 @@ module Cask
|
|||||||
# Start new Cask's installation steps
|
# Start new Cask's installation steps
|
||||||
new_cask_installer.check_conflicts
|
new_cask_installer.check_conflicts
|
||||||
|
|
||||||
new_cask_installer.print_caveats
|
puts new_cask_installer.print_caveats
|
||||||
|
|
||||||
new_cask_installer.fetch
|
new_cask_installer.fetch
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ module Cask
|
|||||||
caveats = cask.caveats
|
caveats = cask.caveats
|
||||||
return if caveats.empty?
|
return if caveats.empty?
|
||||||
|
|
||||||
ohai "Caveats"
|
"#{ohai_title "Caveats"}\n"\
|
||||||
puts caveats + "\n"
|
"#{caveats}\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
@ -88,7 +88,7 @@ module Cask
|
|||||||
|
|
||||||
check_conflicts
|
check_conflicts
|
||||||
|
|
||||||
print_caveats
|
print print_caveats
|
||||||
fetch
|
fetch
|
||||||
uninstall_existing_cask if reinstall?
|
uninstall_existing_cask if reinstall?
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
require "formulary"
|
require "formulary"
|
||||||
require "cask/cmd/abstract_command"
|
require "cask/cmd/abstract_command"
|
||||||
require "cask/cmd/info"
|
require "cask/cmd"
|
||||||
require "cask/cask_loader"
|
require "cask/cask_loader"
|
||||||
require "cask/installer"
|
require "cask/installer"
|
||||||
|
|
||||||
@ -8,10 +8,8 @@ module Homebrew
|
|||||||
module MissingFormula
|
module MissingFormula
|
||||||
class << self
|
class << self
|
||||||
def reason(name, silent: false)
|
def reason(name, silent: false)
|
||||||
search_for_cask(name)
|
cask_reason(name, silent: false) || blacklisted_reason(name) ||
|
||||||
rescue
|
tap_migration_reason(name) || deleted_reason(name, silent: silent)
|
||||||
blacklisted_reason(name) || tap_migration_reason(name) ||
|
|
||||||
deleted_reason(name, silent: silent)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def blacklisted_reason(name)
|
def blacklisted_reason(name)
|
||||||
@ -180,9 +178,11 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_for_cask(name)
|
def cask_reason(name, silent: false)
|
||||||
cask = Cask::CaskLoader.load(name)
|
cask = Cask::CaskLoader.load(name)
|
||||||
Cask::Cmd::Info.info(cask)
|
return Cask::Cmd::Info.get_info(cask) unless silent
|
||||||
|
rescue Cask::CaskUnavailableError
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
require "extend/os/missing_formula"
|
require "extend/os/missing_formula"
|
||||||
|
@ -23,8 +23,17 @@ describe "brew info", :integration_test do
|
|||||||
setup_remote_tap "homebrew/cask"
|
setup_remote_tap "homebrew/cask"
|
||||||
|
|
||||||
expect { brew "info", "firefox" }
|
expect { brew "info", "firefox" }
|
||||||
.to output(/No available formula with the name "firefox"/).to_stderr
|
.to output(%r{Error:\sNo\savailable\sformula\swith\sthe\sname\s"firefox"\s\n
|
||||||
.and output(/firefox/).to_stdout
|
firefox:\s\d+.?\d*\s\(auto_updates\)\n
|
||||||
|
https:\/\/www.mozilla.org\/firefox\/\n
|
||||||
|
Not\sinstalled\n
|
||||||
|
.*\n
|
||||||
|
==>\sName\n
|
||||||
|
Mozilla\sFirefox\n
|
||||||
|
==>\sLanguages\n
|
||||||
|
.*\n
|
||||||
|
==>\sArtifacts\n
|
||||||
|
Firefox.app\s\(App\)\n}x).to_stderr
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,9 +23,13 @@ rescue LoadError => e
|
|||||||
raise unless e.message.include?(path)
|
raise unless e.message.include?(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ohai(title, *sput)
|
def ohai_title(title)
|
||||||
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
|
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
|
||||||
puts Formatter.headline(title, color: :blue)
|
Formatter.headline(title, color: :blue)
|
||||||
|
end
|
||||||
|
|
||||||
|
def ohai(title, *sput)
|
||||||
|
puts ohai_title(title)
|
||||||
puts sput
|
puts sput
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user