Class: Cask::Cmd::Zap Private

Inherits:
AbstractCommand show all
Extended by:
T::Sig
Defined in:
cask/cmd/zap.rb

Overview

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.

Cask implementation for the brew uninstall command.

Constant Summary

Constants inherited from AbstractCommand

AbstractCommand::OPTIONS

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractCommand

abstract?, command_name, help, #initialize, run, short_description, visible?

Methods included from Homebrew::Search

#query_regexp, #search_casks, #search_descriptions, #search_formulae, #search_taps

Methods included from Homebrew::Search::Extension

#search_casks, #search_descriptions

Constructor Details

This class inherits a constructor from Cask::Cmd::AbstractCommand

Class Method Details

.parserObject

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.



12
13
14
15
16
17
# File 'cask/cmd/zap.rb', line 12

def self.parser
  super do
    switch "--force",
           description: "Ignore errors when removing files."
  end
end

.zap_casks(*casks, force: nil, verbose: nil) ⇒ 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.

Parameters:

  • casks (Cask)
  • force (Boolean, nil) (defaults to: nil)
  • verbose (Boolean, nil) (defaults to: nil)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'cask/cmd/zap.rb', line 25

def self.zap_casks(
  *casks,
  force: nil,
  verbose: nil
)
  require "cask/installer"

  casks.each do |cask|
    odebug "Zapping Cask #{cask}"

    if cask.installed?
      if (installed_caskfile = cask.installed_caskfile) && installed_caskfile.exist?
        # Use the same cask file that was used for installation, if possible.
        cask = CaskLoader.load(installed_caskfile)
      end
    else
      raise CaskNotInstalledError, cask unless force
    end

    Installer.new(cask, verbose: verbose, force: force).zap
  end
end

Instance Method Details

#runvoid

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.



20
21
22
# File 'cask/cmd/zap.rb', line 20

def run
  self.class.zap_casks(*casks, verbose: args.verbose?, force: args.force?)
end