48 lines
1.4 KiB
Ruby
Raw Normal View History

2015-06-08 18:05:58 +08:00
require "tap"
require "core_formula_repository"
2015-06-08 18:05:58 +08:00
module Homebrew
2012-03-02 20:28:54 +00:00
def tap
if ARGV.empty?
2015-06-08 18:05:58 +08:00
puts Tap.names
elsif ARGV.first == "--repair"
Tap.each(&:link_manpages)
migrate_taps :force => true
elsif ARGV.first == "--list-official"
require "official_taps"
2015-08-21 12:33:33 +08:00
puts OFFICIAL_TAPS.map { |t| "homebrew/#{t}" }
elsif ARGV.first == "--list-pinned"
puts Tap.select(&:pinned?).map(&:name)
2012-03-02 20:28:54 +00:00
else
tap = Tap.fetch(ARGV[0])
2015-11-10 18:33:57 +08:00
begin
2015-11-10 09:12:25 +00:00
tap.install(:clone_target => ARGV.named[1],
:full_clone => ARGV.include?("--full"))
2015-11-10 18:33:57 +08:00
rescue TapAlreadyTappedError => e
opoo e
2015-11-10 09:12:25 +00:00
end
2012-03-02 20:28:54 +00:00
end
end
2015-11-07 16:25:34 +08:00
# @deprecated this method will be removed in the future, if no external commands use it.
def install_tap(user, repo, clone_target = nil)
2015-11-07 16:25:34 +08:00
opoo "Homebrew.install_tap is deprecated, use Tap#install."
tap = Tap.fetch(user, repo)
begin
2015-11-07 16:25:34 +08:00
tap.install(:clone_target => clone_target, :full_clone => ARGV.include?("--full"))
rescue TapAlreadyTappedError
false
else
true
end
end
# Migrate tapped formulae from symlink-based to directory-based structure.
def migrate_taps(options = {})
ignore = HOMEBREW_LIBRARY/"Formula/.gitignore"
return unless ignore.exist? || options.fetch(:force, false)
(HOMEBREW_LIBRARY/"Formula").children.each { |c| c.unlink if c.symlink? }
ignore.unlink if ignore.exist?
end
2012-03-16 12:49:09 +00:00
end