brew/Library/Homebrew/cmd/migrate.rb

48 lines
1.2 KiB
Ruby
Raw Normal View History

2016-04-08 16:28:43 +02:00
#: * `migrate` [`--force`] <formulae>:
#: Migrate renamed packages to new name, where <formulae> are old names of
#: packages.
#:
2017-04-02 10:14:21 +01:00
#: If `--force` (or `-f`) is passed, then treat installed <formulae> and passed <formulae>
2016-04-08 16:28:43 +02:00
#: like if they are from same taps and migrate them anyway.
require "migrator"
2018-11-05 12:46:57 +05:30
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>] <formulae>
Migrate renamed packages to new name, where <formulae> are old names of
packages.
EOS
switch :force,
description: "Treat installed <formulae> and passed <formulae> like if they are from "\
"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