Merge pull request #7638 from MikeMcQuaid/kill-argv
Remove HomebrewArgvExtension
This commit is contained in:
commit
e6dda524de
@ -50,7 +50,7 @@ begin
|
|||||||
help_flag = !ENV["HOMEBREW_HELP"].nil?
|
help_flag = !ENV["HOMEBREW_HELP"].nil?
|
||||||
cmd = nil
|
cmd = nil
|
||||||
|
|
||||||
ARGV.dup.each_with_index do |arg, i|
|
ARGV.each_with_index do |arg, i|
|
||||||
break if help_flag && cmd
|
break if help_flag && cmd
|
||||||
|
|
||||||
if arg == "help" && !cmd
|
if arg == "help" && !cmd
|
||||||
|
|||||||
@ -38,7 +38,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def audit
|
def audit
|
||||||
if !ARGV.value("language") && language_blocks
|
if !Homebrew.args.value("language") && language_blocks
|
||||||
audit_all_languages
|
audit_all_languages
|
||||||
else
|
else
|
||||||
audit_cask_instance(cask)
|
audit_cask_instance(cask)
|
||||||
|
|||||||
@ -10,7 +10,7 @@ module Homebrew
|
|||||||
# undefine tap to allow --tap argument
|
# undefine tap to allow --tap argument
|
||||||
undef tap
|
undef tap
|
||||||
|
|
||||||
def initialize(argv = ARGV.dup.freeze, set_default_args: false)
|
def initialize(argv = ARGV.freeze, set_default_args: false)
|
||||||
super()
|
super()
|
||||||
|
|
||||||
@processed_options = []
|
@processed_options = []
|
||||||
@ -177,6 +177,14 @@ module Homebrew
|
|||||||
formulae.any? { |args_f| args_f.full_name == f.full_name }
|
formulae.any? { |args_f| args_f.full_name == f.full_name }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def value(name)
|
||||||
|
arg_prefix = "--#{name}="
|
||||||
|
flag_with_value = flags_only.find { |arg| arg.start_with?(arg_prefix) }
|
||||||
|
return unless flag_with_value
|
||||||
|
|
||||||
|
flag_with_value.delete_prefix(arg_prefix)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def option_to_name(option)
|
def option_to_name(option)
|
||||||
|
|||||||
@ -13,7 +13,7 @@ module Homebrew
|
|||||||
class Parser
|
class Parser
|
||||||
attr_reader :processed_options, :hide_from_man_page
|
attr_reader :processed_options, :hide_from_man_page
|
||||||
|
|
||||||
def self.parse(argv = ARGV.dup.freeze, allow_no_named_args: false, &block)
|
def self.parse(argv = ARGV.freeze, allow_no_named_args: false, &block)
|
||||||
new(argv, &block).parse(allow_no_named_args: allow_no_named_args)
|
new(argv, &block).parse(allow_no_named_args: allow_no_named_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ module Homebrew
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(argv = ARGV.dup.freeze, &block)
|
def initialize(argv = ARGV.freeze, &block)
|
||||||
@parser = OptionParser.new
|
@parser = OptionParser.new
|
||||||
@argv = argv
|
@argv = argv
|
||||||
@args = Homebrew::CLI::Args.new(@argv)
|
@args = Homebrew::CLI::Args.new(@argv)
|
||||||
|
|||||||
@ -19,7 +19,7 @@ module Homebrew
|
|||||||
|
|
||||||
def irb_args
|
def irb_args
|
||||||
# work around IRB modifying ARGV.
|
# work around IRB modifying ARGV.
|
||||||
Homebrew::CLI::Parser.new(ARGV.dup) do
|
Homebrew::CLI::Parser.new(ARGV.dup.freeze) do
|
||||||
usage_banner <<~EOS
|
usage_banner <<~EOS
|
||||||
`irb` [<options>]
|
`irb` [<options>]
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module HomebrewArgvExtension
|
|
||||||
def value(name)
|
|
||||||
arg_prefix = "--#{name}="
|
|
||||||
flag_with_value = find { |arg| arg.start_with?(arg_prefix) }
|
|
||||||
flag_with_value&.delete_prefix(arg_prefix)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -746,7 +746,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
formula.options.each do |opt|
|
formula.options.each do |opt|
|
||||||
name = opt.name[/^([^=]+)=$/, 1]
|
name = opt.name[/^([^=]+)=$/, 1]
|
||||||
value = ARGV.value(name) if name
|
value = Homebrew.args.value(name) if name
|
||||||
args << "--#{name}=#{value}" if value
|
args << "--#{name}=#{value}" if value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -35,13 +35,10 @@ require "env_config"
|
|||||||
|
|
||||||
require "config"
|
require "config"
|
||||||
require "os"
|
require "os"
|
||||||
require "extend/ARGV"
|
|
||||||
require "cli/args"
|
require "cli/args"
|
||||||
require "messages"
|
require "messages"
|
||||||
require "system_command"
|
require "system_command"
|
||||||
|
|
||||||
ARGV.extend(HomebrewArgvExtension)
|
|
||||||
|
|
||||||
HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"]
|
HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"]
|
||||||
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
|
HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"]
|
||||||
HOMEBREW_WWW = "https://brew.sh"
|
HOMEBREW_WWW = "https://brew.sh"
|
||||||
|
|||||||
@ -42,11 +42,7 @@ module OS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def languages
|
def languages
|
||||||
@languages ||= [
|
@languages ||= [*ENV["LANG"]&.slice(/[a-z]+/)].uniq
|
||||||
*ARGV.value("language")&.split(","),
|
|
||||||
*ENV["HOMEBREW_LANGUAGES"]&.split(","),
|
|
||||||
*ENV["LANG"]&.slice(/[a-z]+/),
|
|
||||||
].uniq
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def language
|
def language
|
||||||
|
|||||||
@ -60,9 +60,11 @@ module OS
|
|||||||
|
|
||||||
def languages
|
def languages
|
||||||
@languages ||= [
|
@languages ||= [
|
||||||
*ARGV.value("language")&.split(","),
|
*Homebrew.args.value("language")&.split(","),
|
||||||
*ENV["HOMEBREW_LANGUAGES"]&.split(","),
|
*ENV["HOMEBREW_LANGUAGES"]&.split(","),
|
||||||
*Open3.capture2("defaults", "read", "-g", "AppleLanguages")[0].scan(/[^ \n"(),]+/),
|
*Open3.capture2("defaults", "read", "-g", "AppleLanguages")
|
||||||
|
.first
|
||||||
|
.scan(/[^ \n"(),]+/),
|
||||||
].uniq
|
].uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require "extend/ARGV"
|
|
||||||
|
|
||||||
describe HomebrewArgvExtension do
|
|
||||||
subject { argv.extend(described_class) }
|
|
||||||
|
|
||||||
let(:argv) { ["mxcl"] }
|
|
||||||
|
|
||||||
describe "#value" do
|
|
||||||
let(:argv) { ["--foo=", "--bar=ab"] }
|
|
||||||
|
|
||||||
it "returns the value for a given string" do
|
|
||||||
expect(subject.value("foo")).to eq ""
|
|
||||||
expect(subject.value("bar")).to eq "ab"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns nil if there is no matching argument" do
|
|
||||||
expect(subject.value("baz")).to be nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -48,8 +48,6 @@ describe FormulaInstaller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "basic installation" do
|
specify "basic installation" do
|
||||||
ARGV << "--with-invalid_flag" # added to ensure it doesn't fail install
|
|
||||||
|
|
||||||
temporary_install(Testball.new) do |f|
|
temporary_install(Testball.new) do |f|
|
||||||
# Test that things made it into the Keg
|
# Test that things made it into the Keg
|
||||||
expect(f.prefix/"readme").to exist
|
expect(f.prefix/"readme").to exist
|
||||||
|
|||||||
@ -172,7 +172,6 @@ RSpec.configure do |config|
|
|||||||
|
|
||||||
@__files_before_test = find_files
|
@__files_before_test = find_files
|
||||||
|
|
||||||
@__argv = ARGV.dup
|
|
||||||
@__env = ENV.to_hash # dup doesn't work on ENV
|
@__env = ENV.to_hash # dup doesn't work on ENV
|
||||||
|
|
||||||
@__stdout = $stdout.clone
|
@__stdout = $stdout.clone
|
||||||
@ -187,7 +186,6 @@ RSpec.configure do |config|
|
|||||||
rescue SystemExit => e
|
rescue SystemExit => e
|
||||||
raise "Unexpected exit with status #{e.status}."
|
raise "Unexpected exit with status #{e.status}."
|
||||||
ensure
|
ensure
|
||||||
ARGV.replace(@__argv)
|
|
||||||
ENV.replace(@__env)
|
ENV.replace(@__env)
|
||||||
|
|
||||||
$stdout.reopen(@__stdout)
|
$stdout.reopen(@__stdout)
|
||||||
|
|||||||
@ -35,7 +35,7 @@ describe Utils::Bottles::Collector do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "ignores HOMEBREW_SKIP_OR_LATER_BOTTLES on release versions", :needs_macos do
|
it "ignores HOMEBREW_SKIP_OR_LATER_BOTTLES on release versions", :needs_macos do
|
||||||
allow(ARGV).to receive(:skip_or_later_bottles?).and_return(true)
|
allow(Homebrew::EnvConfig).to receive(:skip_or_later_bottles?).and_return(true)
|
||||||
allow(OS::Mac).to receive(:prerelease?).and_return(false)
|
allow(OS::Mac).to receive(:prerelease?).and_return(false)
|
||||||
subject[:mavericks] = "foo"
|
subject[:mavericks] = "foo"
|
||||||
expect(subject.send(:find_matching_tag, :mavericks)).to eq(:mavericks)
|
expect(subject.send(:find_matching_tag, :mavericks)).to eq(:mavericks)
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "tab"
|
require "tab"
|
||||||
require "extend/ARGV"
|
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
class Bottles
|
class Bottles
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user