Merge pull request #7490 from GauthamGoli/argv-cleanup-25

ARGV: Deprecate ARGV.flags_only and replace with Homebrew.args.flags_only
This commit is contained in:
Mike McQuaid 2020-05-03 13:41:07 +01:00 committed by GitHub
commit 92f26e991c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 14 deletions

View File

@ -1,10 +1,6 @@
# frozen_string_literal: true
module HomebrewArgvExtension
def flags_only
select { |arg| arg.start_with?("--") }
end
def value(name)
arg_prefix = "--#{name}="
flag_with_value = find { |arg| arg.start_with?(arg_prefix) }

View File

@ -11,6 +11,7 @@ require "patch"
require "compilers"
require "global"
require "os/mac/version"
require "cli/parser"
class SoftwareSpec
extend Forwardable
@ -41,7 +42,7 @@ class SoftwareSpec
@bottle_specification = BottleSpecification.new
@patches = []
@options = Options.new
@flags = ARGV.flags_only
@flags = Homebrew.args.flags_only
@deprecated_flags = []
@deprecated_options = []
@build = BuildOptions.new(Options.create(@flags), options)

View File

@ -31,14 +31,6 @@ describe HomebrewArgvExtension do
end
end
describe "#flags_only" do
let(:argv) { ["--foo", "-vds", "a", "b", "cdefg"] }
it "returns an array of flags" do
expect(subject.flags_only).to eq ["--foo"]
end
end
describe "#empty?" do
let(:argv) { [] }

View File

@ -76,7 +76,8 @@ describe Messages do
# rubocop:disable RSpec/VerifiedDoubles
context "when the --display-times argument is present" do
before do
allow(Homebrew).to receive(:args).and_return(double(display_times?: true))
allow(Homebrew).to receive(:args)
.and_return(double(display_times?: true, flags_only: ["--display-times"]))
end
context "when install_times is empty" do