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
|
||||
casks.each do |cask|
|
||||
Installer.print_caveats(cask)
|
||||
puts Installer.print_caveats(cask)
|
||||
ohai "Downloading external files for Cask #{cask}"
|
||||
downloaded_path = Download.new(cask, force: force?, quarantine: quarantine?).perform
|
||||
Verify.all(cask, downloaded_path)
|
||||
|
@ -25,21 +25,25 @@ module Cask
|
||||
"displays information about the given Cask"
|
||||
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)
|
||||
title_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)
|
||||
puts get_info(cask)
|
||||
end
|
||||
|
||||
def self.title_info(cask)
|
||||
title = "#{cask.token}: #{cask.version}"
|
||||
title += " (auto_updates)" if cask.auto_updates
|
||||
puts title
|
||||
title
|
||||
end
|
||||
|
||||
def self.formatted_url(url)
|
||||
@ -50,27 +54,28 @@ module Cask
|
||||
if cask.installed?
|
||||
cask.versions.each do |version|
|
||||
versioned_staged_path = cask.caskroom_path.join(version)
|
||||
|
||||
puts versioned_staged_path.to_s
|
||||
.concat(" (")
|
||||
.concat(versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist"))
|
||||
.concat(")")
|
||||
message = versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist")
|
||||
versioned_staged_path.to_s.concat(" (").concat(message).concat(")")
|
||||
end
|
||||
else
|
||||
puts "Not installed"
|
||||
"Not installed"
|
||||
end
|
||||
end
|
||||
|
||||
def self.name_info(cask)
|
||||
ohai((cask.name.size > 1) ? "Names" : "Name")
|
||||
puts cask.name.empty? ? Formatter.error("None") : cask.name
|
||||
<<~EOS
|
||||
#{ohai_title((cask.name.size > 1) ? "Names" : "Name")}
|
||||
#{cask.name.empty? ? Formatter.error("None") : cask.name.join("\n")}
|
||||
EOS
|
||||
end
|
||||
|
||||
def self.language_info(cask)
|
||||
return if cask.languages.empty?
|
||||
|
||||
ohai "Languages"
|
||||
puts cask.languages.join(", ")
|
||||
<<~EOS
|
||||
#{ohai_title("Languages")}
|
||||
#{cask.languages.join(", ")}
|
||||
EOS
|
||||
end
|
||||
|
||||
def self.repo_info(cask)
|
||||
@ -82,16 +87,18 @@ module Cask
|
||||
"#{cask.tap.default_remote}/blob/master/Casks/#{cask.token}.rb"
|
||||
end
|
||||
|
||||
puts "From: #{Formatter.url(url)}"
|
||||
"From: #{Formatter.url(url)}\n"
|
||||
end
|
||||
|
||||
def self.artifact_info(cask)
|
||||
ohai "Artifacts"
|
||||
cask.artifacts.each do |artifact|
|
||||
next unless artifact.respond_to?(:install_phase)
|
||||
next unless DSL::ORDINARY_ARTIFACT_CLASSES.include?(artifact.class)
|
||||
|
||||
puts artifact.to_s
|
||||
return <<~EOS
|
||||
#{ohai_title("Artifacts")}
|
||||
#{artifact}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -74,7 +74,7 @@ module Cask
|
||||
# Start new Cask's installation steps
|
||||
new_cask_installer.check_conflicts
|
||||
|
||||
new_cask_installer.print_caveats
|
||||
puts new_cask_installer.print_caveats
|
||||
|
||||
new_cask_installer.fetch
|
||||
|
||||
|
@ -49,8 +49,8 @@ module Cask
|
||||
caveats = cask.caveats
|
||||
return if caveats.empty?
|
||||
|
||||
ohai "Caveats"
|
||||
puts caveats + "\n"
|
||||
"#{ohai_title "Caveats"}\n"\
|
||||
"#{caveats}\n"
|
||||
end
|
||||
|
||||
def fetch
|
||||
@ -88,7 +88,7 @@ module Cask
|
||||
|
||||
check_conflicts
|
||||
|
||||
print_caveats
|
||||
print print_caveats
|
||||
fetch
|
||||
uninstall_existing_cask if reinstall?
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
require "formulary"
|
||||
require "cask/cmd/abstract_command"
|
||||
require "cask/cmd/info"
|
||||
require "cask/cmd"
|
||||
require "cask/cask_loader"
|
||||
require "cask/installer"
|
||||
|
||||
@ -8,10 +8,8 @@ module Homebrew
|
||||
module MissingFormula
|
||||
class << self
|
||||
def reason(name, silent: false)
|
||||
search_for_cask(name)
|
||||
rescue
|
||||
blacklisted_reason(name) || tap_migration_reason(name) ||
|
||||
deleted_reason(name, silent: silent)
|
||||
cask_reason(name, silent: false) || blacklisted_reason(name) ||
|
||||
tap_migration_reason(name) || deleted_reason(name, silent: silent)
|
||||
end
|
||||
|
||||
def blacklisted_reason(name)
|
||||
@ -180,9 +178,11 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def search_for_cask(name)
|
||||
def cask_reason(name, silent: false)
|
||||
cask = Cask::CaskLoader.load(name)
|
||||
Cask::Cmd::Info.info(cask)
|
||||
return Cask::Cmd::Info.get_info(cask) unless silent
|
||||
rescue Cask::CaskUnavailableError
|
||||
nil
|
||||
end
|
||||
|
||||
require "extend/os/missing_formula"
|
||||
|
@ -23,8 +23,17 @@ describe "brew info", :integration_test do
|
||||
setup_remote_tap "homebrew/cask"
|
||||
|
||||
expect { brew "info", "firefox" }
|
||||
.to output(/No available formula with the name "firefox"/).to_stderr
|
||||
.and output(/firefox/).to_stdout
|
||||
.to output(%r{Error:\sNo\savailable\sformula\swith\sthe\sname\s"firefox"\s\n
|
||||
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
|
||||
|
||||
|
@ -23,9 +23,13 @@ rescue LoadError => e
|
||||
raise unless e.message.include?(path)
|
||||
end
|
||||
|
||||
def ohai(title, *sput)
|
||||
def ohai_title(title)
|
||||
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
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user