Port Homebrew::Cmd::InstallCmd
This commit is contained in:
parent
d25956668d
commit
0fd082a1ff
@ -217,7 +217,7 @@ class Build
|
|||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
args = Homebrew.install_args.parse
|
args = Homebrew::Cmd::InstallCmd.new.args
|
||||||
Context.current = args.context
|
Context.current = args.context
|
||||||
|
|
||||||
error_pipe = UNIXSocket.open(ENV.fetch("HOMEBREW_ERROR_PIPE"), &:recv_io)
|
error_pipe = UNIXSocket.open(ENV.fetch("HOMEBREW_ERROR_PIPE"), &:recv_io)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cask/config"
|
require "cask/config"
|
||||||
require "cask/installer"
|
require "cask/installer"
|
||||||
require "cask_dependent"
|
require "cask_dependent"
|
||||||
@ -9,13 +10,12 @@ require "formula_installer"
|
|||||||
require "development_tools"
|
require "development_tools"
|
||||||
require "install"
|
require "install"
|
||||||
require "cleanup"
|
require "cleanup"
|
||||||
require "cli/parser"
|
|
||||||
require "upgrade"
|
require "upgrade"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
sig { returns(CLI::Parser) }
|
module Cmd
|
||||||
def self.install_args
|
class InstallCmd < AbstractCommand
|
||||||
Homebrew::CLI::Parser.new do
|
cmd_args do
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Install a <formula> or <cask>. Additional options specific to a <formula> may be
|
Install a <formula> or <cask>. Additional options specific to a <formula> may be
|
||||||
appended to the command.
|
appended to the command.
|
||||||
@ -50,8 +50,9 @@ module Homebrew
|
|||||||
}],
|
}],
|
||||||
[:switch, "--ignore-dependencies", {
|
[:switch, "--ignore-dependencies", {
|
||||||
description: "An unsupported Homebrew development option to skip installing any dependencies of any " \
|
description: "An unsupported Homebrew development option to skip installing any dependencies of any " \
|
||||||
"kind. If the dependencies are not already present, the formula will have issues. If you're " \
|
"kind. If the dependencies are not already present, the formula will have issues. If " \
|
||||||
"not developing Homebrew, consider adjusting your PATH rather than using this option.",
|
"you're not developing Homebrew, consider adjusting your PATH rather than using this " \
|
||||||
|
"option.",
|
||||||
}],
|
}],
|
||||||
[:switch, "--only-dependencies", {
|
[:switch, "--only-dependencies", {
|
||||||
description: "Install the dependencies with specified options but do not install the " \
|
description: "Install the dependencies with specified options but do not install the " \
|
||||||
@ -161,11 +162,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args [:formula, :cask], min: 1
|
named_args [:formula, :cask], min: 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def self.install
|
|
||||||
args = install_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
if args.env.present?
|
if args.env.present?
|
||||||
# Can't use `replacement: false` because `install_args` are used by
|
# Can't use `replacement: false` because `install_args` are used by
|
||||||
# `build.rb`. Instead, `hide_from_man_page` and don't do anything with
|
# `build.rb`. Instead, `hide_from_man_page` and don't do anything with
|
||||||
@ -194,8 +193,10 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
formulae, casks = args.named.to_formulae_and_casks(warn: false)
|
formulae, casks = T.cast(
|
||||||
.partition { |formula_or_cask| formula_or_cask.is_a?(Formula) }
|
args.named.to_formulae_and_casks(warn: false).partition { _1.is_a?(Formula) },
|
||||||
|
[T::Array[Formula], T::Array[Cask::Cask]],
|
||||||
|
)
|
||||||
rescue FormulaOrCaskUnavailableError, Cask::CaskUnavailableError
|
rescue FormulaOrCaskUnavailableError, Cask::CaskUnavailableError
|
||||||
cask_tap = CoreCaskTap.instance
|
cask_tap = CoreCaskTap.instance
|
||||||
if !cask_tap.installed? && (args.cask? || Tap.untapped_official_taps.exclude?(cask_tap.name))
|
if !cask_tap.installed? && (args.cask? || Tap.untapped_official_taps.exclude?(cask_tap.name))
|
||||||
@ -405,4 +406,6 @@ module Homebrew
|
|||||||
|
|
||||||
odie "No #{package_types.join(" or ")} found for #{name}."
|
odie "No #{package_types.join(" or ")} found for #{name}."
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cmd/install"
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
RSpec.describe "brew install" do
|
RSpec.describe Homebrew::Cmd::InstallCmd do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "installs formulae", :integration_test do
|
it "installs formulae", :integration_test do
|
||||||
|
|||||||
@ -70,7 +70,7 @@ RSpec.describe FormulaInstaller do
|
|||||||
# rubocop:disable RSpec/NoExpectationExample
|
# rubocop:disable RSpec/NoExpectationExample
|
||||||
specify "basic bottle install" do
|
specify "basic bottle install" do
|
||||||
allow(DevelopmentTools).to receive(:installed?).and_return(false)
|
allow(DevelopmentTools).to receive(:installed?).and_return(false)
|
||||||
Homebrew.install_args.parse(["testball_bottle"])
|
Homebrew::Cmd::InstallCmd.new(["testball_bottle"])
|
||||||
temporarily_install_bottle(TestballBottle.new) do |f|
|
temporarily_install_bottle(TestballBottle.new) do |f|
|
||||||
test_basic_formula_setup(f)
|
test_basic_formula_setup(f)
|
||||||
end
|
end
|
||||||
@ -79,7 +79,7 @@ RSpec.describe FormulaInstaller do
|
|||||||
|
|
||||||
specify "basic bottle install with cellar information on sha256 line" do
|
specify "basic bottle install with cellar information on sha256 line" do
|
||||||
allow(DevelopmentTools).to receive(:installed?).and_return(false)
|
allow(DevelopmentTools).to receive(:installed?).and_return(false)
|
||||||
Homebrew.install_args.parse(["testball_bottle_cellar"])
|
Homebrew::Cmd::InstallCmd.new(["testball_bottle_cellar"])
|
||||||
temporarily_install_bottle(TestballBottleCellar.new) do |f|
|
temporarily_install_bottle(TestballBottleCellar.new) do |f|
|
||||||
test_basic_formula_setup(f)
|
test_basic_formula_setup(f)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user