brew/Library/Homebrew/cmd/migrate.rb

45 lines
1.3 KiB
Ruby
Raw Normal View History

2020-11-25 17:03:23 +01:00
# typed: true
# frozen_string_literal: true
require "migrator"
2019-04-17 18:25:08 +09:00
require "cli/parser"
2023-04-08 14:10:58 +02:00
require "cask/migrator"
module Homebrew
2020-10-20 12:03:48 +02:00
sig { returns(CLI::Parser) }
2023-04-08 14:10:58 +02:00
def self.migrate_args
2018-11-05 12:46:57 +05:30
Homebrew::CLI::Parser.new do
description <<~EOS
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 "-f", "--force",
2022-06-28 10:09:59 +01:00
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."
switch "-n", "--dry-run",
description: "Show what would be migrated, but do not actually migrate anything."
2023-04-08 14:10:58 +02:00
switch "--formula", "--formulae",
description: "Only migrate formulae."
switch "--cask", "--casks",
description: "Only migrate casks."
conflicts "--formula", "--cask"
2020-07-30 18:40:10 +02:00
2023-04-08 14:10:58 +02:00
named_args [:installed_formula, :installed_cask], min: 1
2018-11-05 12:46:57 +05:30
end
end
2023-04-08 14:10:58 +02:00
def self.migrate
args = migrate_args.parse
2018-11-05 12:46:57 +05:30
2023-04-08 14:10:58 +02:00
args.named.to_formulae_and_casks(warn: false).each do |formula_or_cask|
case formula_or_cask
when Formula
Migrator.migrate_if_needed(formula_or_cask, force: args.force?, dry_run: args.dry_run?)
when Cask::Cask
Cask::Migrator.migrate_if_needed(formula_or_cask, dry_run: args.dry_run?)
end
end
end
end