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