Merge pull request #8433 from rolandwalker/remove_homebrew_extend_argv

remove homebrew-fork ARGV monkeypatch
This commit is contained in:
Roland Walker 2014-12-26 14:28:31 -05:00
commit 64ee1394bc
9 changed files with 21 additions and 27 deletions

View file

@ -46,7 +46,7 @@ class Cask::Artifact::Pkg < Cask::Artifact::Base
'-pkg', source,
'-target', '/'
]
args << '-verboseR' if ARGV.verbose?
args << '-verboseR' if Cask.verbose
args << '-allowUntrusted' if pkg_install_opts :allow_untrusted
@command.run!('/usr/sbin/installer', {:sudo => true, :args => args, :print_stdout => true})
end

View file

@ -193,6 +193,9 @@ class Cask::CLI
opts.on("--debug") do |v|
Cask.debug = true
end
opts.on("--verbose") do |v|
Cask.verbose = true
end
opts.on("--outdated") do |v|
Cask.outdated = true
end
@ -216,6 +219,10 @@ class Cask::CLI
"There is more than one possible option that starts with '#{head}'")
end
end
# for compat with Homebrew, not certain if this is desirable
Cask.verbose = true if !ENV['VERBOSE'].nil? or !ENV['HOMEBREW_VERBOSE'].nil?
remaining
end

View file

@ -20,6 +20,14 @@ module Cask::Options
@debug = _debug
end
def verbose
@verbose ||= false
end
def verbose=(_verbose)
@verbose = _verbose
end
def outdated
@outdated ||= false
end

View file

@ -70,7 +70,7 @@ end
# global methods
def ohai(title, *sput)
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
title = Tty.truncate(title) if $stdout.tty? && !Cask.verbose
puts "#{Tty.blue.bold}==>#{Tty.white} #{title}#{Tty.reset}"
puts sput unless sput.empty?
end

View file

@ -13,7 +13,7 @@ class AbstractDownloadStrategy
args = args.dup
args.each_with_index do |arg, ii|
if arg.is_a? Hash
unless ARGV.verbose?
unless Cask.verbose
args[ii] = arg[:quiet_flag]
else
args.delete_at ii
@ -22,7 +22,7 @@ class AbstractDownloadStrategy
end
end
# 2 as default because commands are eg. svn up, git pull
args.insert(2, '-q') unless ARGV.verbose?
args.insert(2, '-q') unless Cask.verbose
args
end

View file

@ -1,13 +0,0 @@
module HomebrewForkArgvExtension
def verbose?
flag? '--verbose' or !ENV['VERBOSE'].nil? or !ENV['HOMEBREW_VERBOSE'].nil?
end
def flag? flag
options_only.include?(flag)
end
def options_only
select { |arg| arg.match('^-') }
end
end

View file

@ -1,10 +1,7 @@
require 'extend/pathname'
require 'extend/ARGV'
require 'exceptions'
require 'utils'
ARGV.extend(HomebrewForkArgvExtension)
def cache
if ENV['HOMEBREW_CACHE']
Pathname.new(ENV['HOMEBREW_CACHE'])

View file

@ -3,7 +3,6 @@
$:.push(File.expand_path(__FILE__+'/../..'))
require 'extend/pathname'
require 'extend/ARGV'
require 'utils'
require 'tmpdir'
@ -24,7 +23,3 @@ MACOS_VERSION = ENV.fetch('MACOS_VERSION') { MACOS_FULL_VERSION[/10\.\d+/] }
# Test environment setup
# needed to keep rspec from attempting to write outside test dir
%w{ENV Formula}.each { |d| HOMEBREW_LIBRARY.join(d).mkpath }
# required for many tests
# eg: undefined method `verbose?' for []:Array
ARGV.extend(HomebrewForkArgvExtension)

View file

@ -4,7 +4,7 @@ require 'os/mac'
require 'utils/popen'
def homebrew_fork_system cmd, *args
puts "#{cmd} #{args*' '}" if ARGV.verbose?
puts "#{cmd} #{args*' '}" if Cask.verbose
pid = fork do
yield if block_given?
args.collect!{|arg| arg.to_s}
@ -35,7 +35,7 @@ def curl *args
raise "#{curl} is not executable" unless curl.exist? and curl.executable?
flags = HOMEBREW_CURL_ARGS
flags = flags.delete("#") if ARGV.verbose?
flags = flags.delete("#") if Cask.verbose
args = [flags, HOMEBREW_USER_AGENT, *args]
# See https://github.com/Homebrew/homebrew/issues/6103