43 lines
967 B
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: false
# frozen_string_literal: true
2018-09-06 08:29:14 +02:00
module Cask
2018-09-04 08:45:48 +01:00
class Cmd
2021-01-25 09:18:10 +00:00
# Cask implementation for the `brew uninstall` command.
2020-08-19 10:34:07 +02:00
#
# @api private
2017-05-20 19:08:03 +02:00
class Zap < AbstractCommand
2020-10-20 12:03:48 +02:00
extend T::Sig
2020-08-01 02:30:46 +02:00
def self.parser
super do
switch "--force",
description: "Ignore errors when removing files."
end
2017-05-20 04:08:59 +02:00
end
2020-10-20 12:03:48 +02:00
sig { void }
2017-05-20 04:08:59 +02:00
def run
2020-11-19 12:57:10 +01:00
self.class.zap_casks(*casks, verbose: args.verbose?, force: args.force?)
end
sig { params(casks: Cask, force: T.nilable(T::Boolean), verbose: T.nilable(T::Boolean)).void }
def self.zap_casks(
*casks,
force: nil,
verbose: nil
)
2020-08-22 09:16:43 +08:00
require "cask/installer"
casks.each do |cask|
odebug "Zapping Cask #{cask}"
2018-04-28 20:12:55 +10:00
raise CaskNotInstalledError, cask if !cask.installed? && !force
2018-04-28 20:12:55 +10:00
2020-11-19 12:57:10 +01:00
Installer.new(cask, verbose: verbose, force: force).zap
2016-09-24 13:52:43 +02:00
end
end
end
2016-08-18 22:11:42 +03:00
end
end