Class: Cask::Cmd::Zap Private

Inherits:
AbstractCommand show all
Defined in:
Library/Homebrew/cask/cmd/zap.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Implementation of the brew cask zap 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?, banner_args, banner_headline, command_name, help, #initialize, max_named, run, short_description, visible?

Methods included from Homebrew::Search

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

Constructor Details

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

Class Method Details

.descriptionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


14
15
16
17
18
19
20
# File 'Library/Homebrew/cask/cmd/zap.rb', line 14

def self.description
  <<~EOS
    Zaps all files associated with the given <cask>. Implicitly also performs all actions associated with `uninstall`.

    *May remove files which are shared between applications.*
  EOS
end

.min_namedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


10
11
12
# File 'Library/Homebrew/cask/cmd/zap.rb', line 10

def self.min_named
  :cask
end

.parserObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


22
23
24
25
26
27
# File 'Library/Homebrew/cask/cmd/zap.rb', line 22

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

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

def run
  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 args.force?
    end

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