From 679c72a81f210076d1c61d4bf293800159cf01d4 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Fri, 26 Dec 2014 12:33:09 -0500 Subject: [PATCH] remove homebrew-fork ARGV monkeypatch --- lib/cask/artifact/pkg.rb | 2 +- lib/cask/cli.rb | 7 +++++++ lib/cask/options.rb | 8 ++++++++ lib/cask/utils.rb | 2 +- .../Library/Homebrew/download_strategy.rb | 4 ++-- lib/homebrew-fork/Library/Homebrew/extend/ARGV.rb | 13 ------------- lib/homebrew-fork/Library/Homebrew/global.rb | 3 --- .../Library/Homebrew/test/testing_env.rb | 5 ----- lib/homebrew-fork/Library/Homebrew/utils.rb | 4 ++-- 9 files changed, 21 insertions(+), 27 deletions(-) delete mode 100644 lib/homebrew-fork/Library/Homebrew/extend/ARGV.rb diff --git a/lib/cask/artifact/pkg.rb b/lib/cask/artifact/pkg.rb index 9e323de5e..659a347f8 100644 --- a/lib/cask/artifact/pkg.rb +++ b/lib/cask/artifact/pkg.rb @@ -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 diff --git a/lib/cask/cli.rb b/lib/cask/cli.rb index 199198ba2..32e7f1d70 100644 --- a/lib/cask/cli.rb +++ b/lib/cask/cli.rb @@ -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 diff --git a/lib/cask/options.rb b/lib/cask/options.rb index a1486f70b..b6fb9ebd9 100644 --- a/lib/cask/options.rb +++ b/lib/cask/options.rb @@ -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 diff --git a/lib/cask/utils.rb b/lib/cask/utils.rb index c1567b829..a9c0b0b72 100644 --- a/lib/cask/utils.rb +++ b/lib/cask/utils.rb @@ -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 diff --git a/lib/homebrew-fork/Library/Homebrew/download_strategy.rb b/lib/homebrew-fork/Library/Homebrew/download_strategy.rb index 1c7346efb..753700934 100644 --- a/lib/homebrew-fork/Library/Homebrew/download_strategy.rb +++ b/lib/homebrew-fork/Library/Homebrew/download_strategy.rb @@ -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 diff --git a/lib/homebrew-fork/Library/Homebrew/extend/ARGV.rb b/lib/homebrew-fork/Library/Homebrew/extend/ARGV.rb deleted file mode 100644 index abbac8f2d..000000000 --- a/lib/homebrew-fork/Library/Homebrew/extend/ARGV.rb +++ /dev/null @@ -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 diff --git a/lib/homebrew-fork/Library/Homebrew/global.rb b/lib/homebrew-fork/Library/Homebrew/global.rb index 3cde343bd..ff3b22bd0 100644 --- a/lib/homebrew-fork/Library/Homebrew/global.rb +++ b/lib/homebrew-fork/Library/Homebrew/global.rb @@ -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']) diff --git a/lib/homebrew-fork/Library/Homebrew/test/testing_env.rb b/lib/homebrew-fork/Library/Homebrew/test/testing_env.rb index 73b19d5d8..d52368ce2 100644 --- a/lib/homebrew-fork/Library/Homebrew/test/testing_env.rb +++ b/lib/homebrew-fork/Library/Homebrew/test/testing_env.rb @@ -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) diff --git a/lib/homebrew-fork/Library/Homebrew/utils.rb b/lib/homebrew-fork/Library/Homebrew/utils.rb index 544342cf9..1775e1dd1 100644 --- a/lib/homebrew-fork/Library/Homebrew/utils.rb +++ b/lib/homebrew-fork/Library/Homebrew/utils.rb @@ -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