brew/Library/Homebrew/cmd/migrate.rb

42 lines
973 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require "migrator"
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
2018-11-05 12:46:57 +05:30
def migrate_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`migrate` [<options>] <formula>
2018-11-05 12:46:57 +05:30
2019-08-06 14:22:24 -04:00
Migrate renamed packages to new names, where <formula> are old names of
2018-11-05 12:46:57 +05:30
packages.
EOS
switch :force,
description: "Treat installed <formula> and provided <formula> as if they are from "\
2019-08-06 14:22:24 -04:00
"the same taps and migrate them anyway."
2018-11-05 12:46:57 +05:30
switch :verbose
switch :debug
min_named :formula
2018-11-05 12:46:57 +05:30
end
end
def migrate
2018-11-05 12:46:57 +05:30
migrate_args.parse
args.resolved_formulae.each do |f|
if f.oldname
unless (rack = HOMEBREW_CELLAR/f.oldname).exist? && !rack.subdirs.empty?
raise NoSuchKegError, f.oldname
end
raise "#{rack} is a symlink" if rack.symlink?
end
migrator = Migrator.new(f)
migrator.migrate
end
end
end