2024-03-10 13:21:40 -07:00
|
|
|
# typed: strict
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-04-01 11:50:25 -07:00
|
|
|
require "abstract_command"
|
2024-03-10 13:21:40 -07:00
|
|
|
require "untap"
|
2018-11-11 18:35:55 +05:30
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2024-04-01 11:50:25 -07:00
|
|
|
module Cmd
|
|
|
|
class UntapCmd < AbstractCommand
|
|
|
|
cmd_args do
|
|
|
|
description <<~EOS
|
|
|
|
Remove a tapped formula repository.
|
|
|
|
EOS
|
|
|
|
switch "-f", "--force",
|
|
|
|
description: "Untap even if formulae or casks from this tap are currently installed."
|
|
|
|
|
|
|
|
named_args :tap, min: 1
|
|
|
|
end
|
2021-10-28 17:13:34 -04:00
|
|
|
|
2024-04-01 11:50:25 -07:00
|
|
|
sig { override.void }
|
|
|
|
def run
|
|
|
|
args.named.to_installed_taps.each do |tap|
|
|
|
|
odie "Untapping #{tap} is not allowed" if tap.core_tap? && Homebrew::EnvConfig.no_install_from_api?
|
|
|
|
|
|
|
|
if Homebrew::EnvConfig.no_install_from_api? || (!tap.core_tap? && !tap.core_cask_tap?)
|
|
|
|
installed_tap_formulae = Untap.installed_formulae_for(tap:)
|
|
|
|
installed_tap_casks = Untap.installed_casks_for(tap:)
|
|
|
|
|
|
|
|
if installed_tap_formulae.present? || installed_tap_casks.present?
|
|
|
|
installed_names = (installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n")
|
|
|
|
if args.force? || Homebrew::EnvConfig.developer?
|
|
|
|
opoo <<~EOS
|
|
|
|
Untapping #{tap} even though it contains the following installed formulae or casks:
|
|
|
|
#{installed_names}
|
|
|
|
EOS
|
|
|
|
else
|
|
|
|
odie <<~EOS
|
|
|
|
Refusing to untap #{tap} because it contains the following installed formulae or casks:
|
|
|
|
#{installed_names}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
2021-10-28 17:13:34 -04:00
|
|
|
end
|
2024-04-01 11:50:25 -07:00
|
|
|
|
|
|
|
tap.uninstall manual: true
|
2020-12-04 21:19:48 +01:00
|
|
|
end
|
|
|
|
end
|
2015-02-01 12:11:54 -05:00
|
|
|
end
|
2012-03-18 00:40:41 +00:00
|
|
|
end
|
2012-03-02 20:28:54 +00:00
|
|
|
end
|