Class: Homebrew::Cmd::UninstallCmd

Inherits:
AbstractCommand show all
Defined in:
cmd/uninstall.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#runvoid

This method returns an undefined value.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'cmd/uninstall.rb', line 43

def run
  all_kegs, casks = args.named.to_kegs_to_casks(
    ignore_unavailable: args.force?,
    all_kegs:           args.force?,
  )

  # If ignore_unavailable is true and the named args
  # are a series of invalid kegs and casks,
  # #to_kegs_to_casks will return empty arrays.
  return if all_kegs.blank? && casks.blank?

  kegs_by_rack = all_kegs.group_by(&:rack)

  Uninstall.uninstall_kegs(
    kegs_by_rack,
    casks:,
    force:               args.force?,
    ignore_dependencies: args.ignore_dependencies?,
    named_args:          args.named,
  )

  if args.zap?
    casks.each do |cask|
      odebug "Zapping Cask #{cask}"

      raise Cask::CaskNotInstalledError, cask if !cask.installed? && !args.force?

      Cask::Installer.new(cask, verbose: args.verbose?, force: args.force?).zap
    end
  else
    Cask::Uninstall.uninstall_casks(
      *casks,
      verbose: args.verbose?,
      force:   args.force?,
    )
  end

  Cleanup.autoremove if Homebrew::EnvConfig.autoremove?
end