aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2017-05-20 03:57:38 +0200
committerMarkus Reiter2017-05-22 02:51:16 +0200
commit101371207f8c6d4bd4da308f96c320232ba9c584 (patch)
tree89e0682e9ca4a15afeb4bd51ad8a4c7d61a967a9 /Library
parent98f91fb88331ee1bc5f190fec827048a38bf8498 (diff)
downloadbrew-101371207f8c6d4bd4da308f96c320232ba9c584.tar.bz2
Refactor `CLI::Uninstall`.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/uninstall.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb
index 7fc40daaf..213c5beb6 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb
@@ -2,22 +2,28 @@ module Hbc
class CLI
class Uninstall < Base
def self.run(*args)
- cask_tokens = cask_tokens_from(args)
- raise CaskUnspecifiedError if cask_tokens.empty?
- force = args.include? "--force"
+ new(*args).run
+ end
+
+ def initialize(*args)
+ @cask_tokens = self.class.cask_tokens_from(args)
+ raise CaskUnspecifiedError if @cask_tokens.empty?
+ @force = args.include? "--force"
+ end
- cask_tokens.each do |cask_token|
+ def run
+ @cask_tokens.each do |cask_token|
odebug "Uninstalling Cask #{cask_token}"
cask = CaskLoader.load(cask_token)
- raise CaskNotInstalledError, cask unless cask.installed? || force
+ 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_from_file(cask.installed_caskfile) if cask.installed_caskfile.exist?
end
- Installer.new(cask, binaries: CLI.binaries?, force: force).uninstall
+ Installer.new(cask, binaries: CLI.binaries?, force: @force).uninstall
next if (versions = cask.versions).empty?