brew/Library/Homebrew/cmd/migrate.rb

45 lines
1.4 KiB
Ruby
Raw Permalink Normal View History

2024-03-31 19:47:42 -07:00
# typed: strict
# frozen_string_literal: true
2024-03-31 19:47:42 -07:00
require "abstract_command"
require "migrator"
2023-04-08 14:10:58 +02:00
require "cask/migrator"
module Homebrew
2024-03-31 19:47:42 -07:00
module Cmd
class Migrate < AbstractCommand
cmd_args do
description <<~EOS
Migrate renamed packages to new names, where <formula> are old names of
packages.
EOS
switch "-f", "--force",
description: "Treat installed <formula> and provided <formula> as if they are from " \
"the same taps and migrate them anyway."
switch "-n", "--dry-run",
description: "Show what would be migrated, but do not actually migrate anything."
switch "--formula", "--formulae",
description: "Only migrate formulae."
switch "--cask", "--casks",
description: "Only migrate casks."
2023-04-08 14:10:58 +02:00
2024-03-31 19:47:42 -07:00
conflicts "--formula", "--cask"
2020-07-30 18:40:10 +02:00
2024-03-31 19:47:42 -07:00
named_args [:installed_formula, :installed_cask], min: 1
end
2018-11-05 12:46:57 +05:30
2024-03-31 19:47:42 -07:00
sig { override.void }
def run
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
2023-04-08 14:10:58 +02:00
end
end
end
end