Class: Cask::Uninstall Private
- Extended by:
- Utils::Output::Mixin
- Defined in:
- cask/uninstall.rb
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Class Method Summary collapse
- .check_dependent_casks(*casks, named_args: []) ⇒ void private
- .uninstall_casks(*casks, binaries: false, force: false, verbose: false, dry_run: false) ⇒ Array<::Cask::Cask> private
- .unpin_for_removal?(cask, force:, dry_run: false) ⇒ Boolean private
Methods included from Utils::Output::Mixin
issue_reporting_message, odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_once, opoo_outside_github_actions, opoo_without_github_actions_annotation, pretty_cannot_install, pretty_deprecated, pretty_disabled, pretty_duration, pretty_install_status, pretty_installed, pretty_removed, pretty_uninstalled, pretty_unmarked, pretty_upgradable, pretty_warning
Class Method Details
.check_dependent_casks(*casks, named_args: []) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'cask/uninstall.rb', line 76 def self.check_dependent_casks(*casks, named_args: []) dependents = [] all_requireds = casks.map(&:token) requireds = Set.new caskroom = ::Cask::Caskroom.casks caskroom.each do |dependent| next if all_requireds.include?(dependent.token) d = CaskDependent.new(dependent) dependencies = d.recursive_requirements.filter_map { |r| r.cask if r.is_a?(CaskDependent::Requirement) } found_dependents = dependencies.intersection(all_requireds) next if found_dependents.empty? requireds += found_dependents dependents << dependent.token end return if dependents.empty? DependentsMessage.new(requireds.to_a, dependents, named_args:).output end |
.uninstall_casks(*casks, binaries: false, force: false, verbose: false, dry_run: false) ⇒ Array<::Cask::Cask>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'cask/uninstall.rb', line 21 def self.uninstall_casks(*casks, binaries: false, force: false, verbose: false, dry_run: false) require "cask/installer" caught_exceptions = [] casks_to_uninstall = [] casks.each do |cask| odebug "Uninstalling Cask #{cask}" if !cask.installed? && !force if dry_run ofail CaskNotInstalledError.new(cask) next end raise CaskNotInstalledError, cask end next unless unpin_for_removal?(cask, force:, dry_run:) Installer.new(cask, binaries:, force:, verbose:).uninstall(dry_run:) casks_to_uninstall << cask rescue => e if dry_run ofail e else caught_exceptions << e end next end return casks_to_uninstall if dry_run return casks_to_uninstall if caught_exceptions.empty? raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1 raise caught_exceptions.fetch(0) end |
.unpin_for_removal?(cask, force:, dry_run: false) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'cask/uninstall.rb', line 61 def self.unpin_for_removal?(cask, force:, dry_run: false) return true unless cask.pinned? unless force onoe "#{cask.full_name} is pinned. You must unpin it to uninstall." return false end return true if dry_run cask.unpin true end |