54 lines
1.6 KiB
Ruby
Raw Normal View History

2020-11-25 17:03:23 +01:00
# typed: true
# frozen_string_literal: true
2019-04-17 18:25:08 +09:00
require "cli/parser"
2018-11-11 18:35:55 +05:30
module Homebrew
2020-10-20 12:03:48 +02:00
extend T::Sig
2016-09-26 01:44:51 +02:00
module_function
2020-10-20 12:03:48 +02:00
sig { returns(CLI::Parser) }
2018-11-11 18:35:55 +05:30
def untap_args
Homebrew::CLI::Parser.new do
description <<~EOS
Remove a tapped formula repository.
2018-11-11 18:35:55 +05:30
EOS
2021-02-04 18:36:32 +01:00
switch "-f", "--force",
description: "Untap even if formulae or casks from this tap are currently installed."
2020-07-30 18:40:10 +02:00
2021-01-10 14:26:40 -05:00
named_args :tap, min: 1
2018-11-11 18:35:55 +05:30
end
end
2012-03-02 20:28:54 +00:00
def untap
2020-07-30 18:40:10 +02:00
args = untap_args.parse
2018-11-11 18:35:55 +05:30
2021-01-10 14:26:40 -05:00
args.named.to_installed_taps.each do |tap|
2021-10-22 11:46:54 -04:00
odie "Untapping #{tap} is not allowed" if tap.core_tap? && !Homebrew::EnvConfig.install_from_api?
2018-09-17 02:45:00 +02:00
if !Homebrew::EnvConfig.install_from_api? || (!tap.core_tap? && tap != "homebrew/cask")
installed_tap_formulae = Formula.installed.select { |formula| formula.tap == tap }
installed_tap_casks = Cask::Caskroom.casks.select { |cask| cask.tap == 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
end
tap.uninstall manual: true
end
end
2012-03-02 20:28:54 +00:00
end