brew/Library/Homebrew/cmd/migrate.rb

41 lines
958 B
Ruby
Raw Normal View History

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
Migrate renamed packages to new name, where <formula> are old names of
2018-11-05 12:46:57 +05:30
packages.
EOS
switch :force,
description: "Treat installed <formula> and passed <formula> like if they are from "\
2018-11-05 12:46:57 +05:30
"same taps and migrate them anyway."
switch :verbose
switch :debug
end
end
def migrate
2018-11-05 12:46:57 +05:30
migrate_args.parse
raise FormulaUnspecifiedError if ARGV.named.empty?
ARGV.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