Class: Hbc::CLI::Uninstall

Inherits:
AbstractCommand show all
Defined in:
Library/Homebrew/cask/lib/hbc/cli/uninstall.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractCommand

abstract?, command_name, needs_init?, run, visible

Methods included from Options

included, #process_arguments

Constructor Details

#initializeUninstall

Returns a new instance of Uninstall



6
7
8
9
# File 'Library/Homebrew/cask/lib/hbc/cli/uninstall.rb', line 6

def initialize(*)
  super
  raise CaskUnspecifiedError if args.empty?
end

Class Method Details

.helpObject



35
36
37
# File 'Library/Homebrew/cask/lib/hbc/cli/uninstall.rb', line 35

def self.help
  "uninstalls the given Cask"
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'Library/Homebrew/cask/lib/hbc/cli/uninstall.rb', line 11

def run
  casks.each do |cask|
    odebug "Uninstalling Cask #{cask}"

    raise CaskNotInstalledError, cask unless cask.installed? || force?

    if cask.installed? && !cask.installed_caskfile.nil?
      # use the same cask file that was used for installation, if possible
      cask = CaskLoader.load(cask.installed_caskfile) if cask.installed_caskfile.exist?
    end

    Installer.new(cask, binaries: binaries?, verbose: verbose?, force: force?).uninstall

    next if (versions = cask.versions).empty?

    single = versions.count == 1

    puts <<~EOS
      #{cask} #{versions.join(", ")} #{single ? "is" : "are"} still installed.
      Remove #{single ? "it" : "them all"} with `brew cask uninstall --force #{cask}`.
    EOS
  end
end