extend/ARGV: remove/private unused methods.
This commit is contained in:
parent
66155ea370
commit
495daf0aee
@ -1,18 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module HomebrewArgvExtension
|
||||
def named
|
||||
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
||||
self - options_only
|
||||
end
|
||||
|
||||
def flags_only
|
||||
select { |arg| arg.start_with?("--") }
|
||||
end
|
||||
|
||||
def formulae
|
||||
require "formula"
|
||||
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
||||
(downcased_unique_named - casks).map do |name|
|
||||
if name.include?("/") || File.exist?(name)
|
||||
Formulary.factory(name, spec)
|
||||
@ -33,10 +27,6 @@ module HomebrewArgvExtension
|
||||
flag_with_value&.delete_prefix(arg_prefix)
|
||||
end
|
||||
|
||||
def verbose?
|
||||
flag?("--verbose") || !ENV["VERBOSE"].nil? || !ENV["HOMEBREW_VERBOSE"].nil?
|
||||
end
|
||||
|
||||
def debug?
|
||||
flag?("--debug") || !ENV["HOMEBREW_DEBUG"].nil?
|
||||
end
|
||||
@ -150,9 +140,12 @@ module HomebrewArgvExtension
|
||||
end
|
||||
end
|
||||
|
||||
def named
|
||||
self - options_only
|
||||
end
|
||||
|
||||
def downcased_unique_named
|
||||
# Only lowercase names, not paths, bottle filenames or URLs
|
||||
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
||||
named.map do |arg|
|
||||
if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg)
|
||||
arg
|
||||
|
||||
@ -31,14 +31,14 @@ describe HomebrewArgvExtension do
|
||||
let(:argv) { ["foo", "--debug", "-v"] }
|
||||
|
||||
it "returns an array of non-option arguments" do
|
||||
expect(subject.named).to eq ["foo"]
|
||||
expect(subject.send(:named)).to eq ["foo"]
|
||||
end
|
||||
|
||||
context "when there are no named arguments" do
|
||||
let(:argv) { [] }
|
||||
|
||||
it "returns an empty array" do
|
||||
expect(subject.named).to be_empty
|
||||
expect(subject.send(:named)).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user