Port Homebrew::Cmd::Link
This commit is contained in:
parent
8ab9d2cbad
commit
22bfd9b230
@ -1,16 +1,14 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "abstract_command"
|
||||
require "caveats"
|
||||
require "cli/parser"
|
||||
require "unlink"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def link_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
module Cmd
|
||||
class Link < AbstractCommand
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Symlink all of <formula>'s installed files into Homebrew's prefix.
|
||||
This is done automatically when you install formulae but can be useful
|
||||
@ -28,11 +26,9 @@ module Homebrew
|
||||
|
||||
named_args :installed_formula, min: 1
|
||||
end
|
||||
end
|
||||
|
||||
def link
|
||||
args = link_args.parse
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
options = {
|
||||
overwrite: args.overwrite?,
|
||||
dry_run: args.dry_run?,
|
||||
@ -86,7 +82,8 @@ module Homebrew
|
||||
end
|
||||
|
||||
if keg_only
|
||||
if HOMEBREW_PREFIX.to_s == HOMEBREW_DEFAULT_PREFIX && formula.present? && formula.keg_only_reason.by_macos?
|
||||
if HOMEBREW_PREFIX.to_s == HOMEBREW_DEFAULT_PREFIX && formula.present? &&
|
||||
formula.keg_only_reason.by_macos?
|
||||
caveats = Caveats.new(formula)
|
||||
opoo <<~EOS
|
||||
Refusing to link macOS provided/shadowed software: #{keg.name}
|
||||
@ -122,6 +119,8 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def puts_keg_only_path_message(keg)
|
||||
bin = keg/"bin"
|
||||
sbin = keg/"sbin"
|
||||
@ -132,4 +131,6 @@ module Homebrew
|
||||
puts " #{Utils::Shell.prepend_path_in_profile(opt/"bin")}" if bin.directory?
|
||||
puts " #{Utils::Shell.prepend_path_in_profile(opt/"sbin")}" if sbin.directory?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/link"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe "brew link" do
|
||||
RSpec.describe Homebrew::Cmd::Link do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "links a given Formula", :integration_test do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user