ARGV: Replace ARGV.verbose? with Homebrew.args.verbose?

This commit is contained in:
Gautham Goli 2020-02-01 13:32:39 +01:00
parent 46e3520883
commit acde828a45
16 changed files with 33 additions and 27 deletions

View File

@ -58,7 +58,7 @@ class Cleaner
# actual files gets removed correctly.
dirs.reverse_each do |d|
if d.children.empty?
puts "rmdir: #{d} (empty)" if ARGV.verbose?
puts "rmdir: #{d} (empty)" if Homebrew.args.verbose?
d.rmdir
end
end

View File

@ -64,10 +64,14 @@ module Homebrew
set_constraints(name, required_for: required_for, depends_on: depends_on)
end
enable_switch(*names, from: :env) if !env.nil? && !ENV["HOMEBREW_#{env.to_s.upcase}"].nil?
enable_switch(*names, from: :env) if env?(env)
end
alias switch_option switch
def env?(env)
env.present? && ENV["HOMEBREW_#{env.to_s.upcase}"].present?
end
def usage_banner(text)
@parser.banner = Formatter.wrap("#{text}\n", COMMAND_DESC_WIDTH)
end

View File

@ -60,7 +60,7 @@ class AbstractDownloadStrategy
ref_type: @ref_type, ref: @ref)
.extract_nestedly(basename: basename,
prioritise_extension: true,
verbose: ARGV.verbose? && !shutup)
verbose: Homebrew.args.verbose? && !shutup)
chdir
end
@ -104,7 +104,7 @@ class AbstractDownloadStrategy
*args,
print_stdout: !shutup,
print_stderr: !shutup,
verbose: ARGV.verbose? && !shutup,
verbose: Homebrew.args.verbose? && !shutup,
env: env,
**options,
)
@ -497,7 +497,7 @@ class NoUnzipCurlDownloadStrategy < CurlDownloadStrategy
def stage
UnpackStrategy::Uncompressed.new(cached_location)
.extract(basename: basename,
verbose: ARGV.verbose? && !shutup)
verbose: Homebrew.args.verbose? && !shutup)
end
end
@ -552,7 +552,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
# This saves on bandwidth and will have a similar effect to verifying the
# cache as it will make any changes to get the right revision.
args = []
args << "--quiet" unless ARGV.verbose?
args << "--quiet" unless Homebrew.args.verbose?
if revision
ohai "Checking out #{@ref}"
@ -896,7 +896,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy
end
def quiet_flag
"-Q" unless ARGV.verbose?
"-Q" unless Homebrew.args.verbose?
end
def clone_repo

View File

@ -381,7 +381,7 @@ class BuildError < RuntimeError
def dump
puts
if ARGV.verbose?
if Homebrew.args.verbose?
require "system_config"
require "build_environment"

View File

@ -443,8 +443,8 @@ module ObserverPathnameExtension
MAXIMUM_VERBOSE_OUTPUT = 100
def verbose?
return ARGV.verbose? unless ENV["CI"]
return false unless ARGV.verbose?
return Homebrew.args.verbose? unless ENV["CI"]
return false unless Homebrew.args.verbose?
if total < MAXIMUM_VERBOSE_OUTPUT
true

View File

@ -506,7 +506,7 @@ class Formula
return false unless head&.downloader.is_a?(VCSDownloadStrategy)
downloader = head.downloader
downloader.shutup! unless ARGV.verbose?
downloader.shutup! unless Homebrew.args.verbose?
downloader.commit_outdated?(version.version.commit)
end
@ -1844,7 +1844,7 @@ class Formula
# # If there is a "make", "install" available, please use it!
# system "make", "install"</pre>
def system(cmd, *args)
verbose = ARGV.verbose?
verbose = Homebrew.args.verbose?
verbose_using_dots = !ENV["HOMEBREW_VERBOSE_USING_DOTS"].nil?
# remove "boring" arguments so that the important ones are more likely to

View File

@ -56,7 +56,7 @@ class FormulaInstaller
@include_test = ARGV.include?("--include-test")
@interactive = false
@git = false
@verbose = ARGV.verbose?
@verbose = Homebrew.args.verbose?
@quieter = ARGV.quieter?
@debug = ARGV.debug?
@installed_as_dependency = false

View File

@ -573,7 +573,9 @@ class Keg
begin
keg = Keg.for(src)
rescue NotAKegError
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar" if ARGV.verbose?
if Homebrew.args.verbose?
puts "Won't resolve conflicts for symlink #{dst} as it doesn't resolve into the Cellar"
end
return
end
@ -584,7 +586,7 @@ class Keg
def make_relative_symlink(dst, src, mode)
if dst.symlink? && src == dst.resolved_path
puts "Skipping; link already exists: #{dst}" if ARGV.verbose?
puts "Skipping; link already exists: #{dst}" if Homebrew.args.verbose?
return
end

View File

@ -127,7 +127,7 @@ class Resource
def verify_download_integrity(fn)
if fn.file?
ohai "Verifying #{fn.basename} checksum" if ARGV.verbose?
ohai "Verifying #{fn.basename} checksum" if Homebrew.args.verbose?
fn.verify_checksum(checksum)
end
rescue ChecksumMissingError

View File

@ -127,7 +127,7 @@ class Sandbox
end
end
if @failed && ARGV.verbose?
if @failed && ENV["HOMEBREW_VERBOSE"].present?
ohai "Sandbox log"
puts logs
$stdout.flush # without it, brew test-bot would fail to catch the log

View File

@ -30,7 +30,7 @@ module Homebrew
args << "--parallel"
end
args += ["--extra-details", "--display-cop-names"] if ARGV.verbose?
args += ["--extra-details", "--display-cop-names"] if Homebrew.args.verbose?
if except_cops
except_cops.map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") }

View File

@ -222,7 +222,7 @@ class SystemCommand
end
def warn_plist_garbage(garbage)
return unless ARGV.verbose?
return unless Homebrew.args.verbose?
return unless garbage.match?(/\S/)
opoo "Received non-XML output from #{Formatter.identifier(command.first)}:"

View File

@ -604,7 +604,7 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
desc "foo"
url 'https://brew.sh/foo-1.0.tgz'
def install
verbose = ARGV.verbose?
verbose = Homebrew.args.verbose?
end
end
RUBY

View File

@ -120,7 +120,7 @@ describe SystemCommand::Result do
context "when verbose" do
before do
allow(ARGV).to receive(:verbose?).and_return(true)
allow(Homebrew.args).to receive(:verbose?).and_return(true)
end
it "warns about garbage" do
@ -144,7 +144,7 @@ describe SystemCommand::Result do
context "when verbose" do
before do
allow(ARGV).to receive(:verbose?).and_return(true)
allow(Homebrew.args).to receive(:verbose?).and_return(true)
end
it "warns about garbage" do

View File

@ -35,7 +35,7 @@ module Homebrew
end
def system(cmd, *args, **options)
if ARGV.verbose?
if Homebrew.args.verbose?
puts "#{cmd} #{args * " "}".gsub(RUBY_PATH, "ruby")
.gsub($LOAD_PATH.join(File::PATH_SEPARATOR).to_s, "$LOAD_PATH")
end
@ -87,7 +87,7 @@ module Kernel
end
def ohai_title(title)
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
title = Tty.truncate(title) if $stdout.tty? && !Homebrew.args.verbose?
Formatter.headline(title, color: :blue)
end
@ -104,7 +104,7 @@ module Kernel
end
def oh1(title, options = {})
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose? && options.fetch(:truncate, :auto) == :auto
title = Tty.truncate(title) if $stdout.tty? && !Homebrew.args.verbose? && options.fetch(:truncate, :auto) == :auto
puts Formatter.headline(title, color: :green)
end
@ -373,7 +373,7 @@ module Kernel
end
def nostdout
if ARGV.verbose?
if Homebrew.args.verbose?
yield
else
begin

View File

@ -34,7 +34,7 @@ def curl_args(*extra_args, show_output: false, user_agent: :default)
unless show_output
args << "--fail"
args << "--progress-bar" unless ARGV.verbose?
args << "--progress-bar" unless Homebrew.args.verbose?
args << "--verbose" if ENV["HOMEBREW_CURL_VERBOSE"]
args << "--silent" unless $stdout.tty?
end