ARGV: add .dry_run? method

Add an ARGV.dry_run? helper method for '--dry-run'/'-n' now that
'-n' is being used as a git-style dry-run in two commands.

Closes Homebrew/homebrew#12898.

Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
This commit is contained in:
Misty De Meo 2012-06-17 18:44:35 -05:00
parent 743b5e6feb
commit f17429f842
3 changed files with 9 additions and 9 deletions

View File

@ -16,7 +16,7 @@ module Homebrew extend self
end
clean_cache
# seems like a good time to do some additional cleanup
Homebrew.prune unless ARGV.switch? 'n'
Homebrew.prune unless ARGV.dry_run?
else
ARGV.formulae.each do |f|
cleanup_formula f
@ -39,7 +39,7 @@ module Homebrew extend self
f.rack.children.each do |keg|
if f.installed_prefix != keg
puts "Removing #{keg}..."
rm_rf keg unless ARGV.switch? 'n'
rm_rf keg unless ARGV.dry_run?
end
end
elsif f.rack.children.length > 1
@ -59,7 +59,7 @@ module Homebrew extend self
old_bottle = bottle_file_outdated? f, pn
if not f or (f.version != version or ARGV.switch? "s" and not f.installed?) or old_bottle
puts "Removing #{pn}..."
rm pn unless ARGV.switch? 'n'
rm pn unless ARGV.dry_run?
end
end
end

View File

@ -9,12 +9,9 @@ module Homebrew extend self
abort "Cowardly refusing to `sudo brew link'"
end
if ARGV.force?
mode = :force
elsif ARGV.include?("--dry-run") || ARGV.include?("-n")
mode = :dryrun
else
mode = nil
if ARGV.force? then mode = :force
elsif ARGV.dry_run? then mode = :dryrun
else mode = nil
end
ARGV.kegs.each do |keg|

View File

@ -87,6 +87,9 @@ module HomebrewArgvExtension
def one?
flag? '--1'
end
def dry_run?
include?('--dry-run') || switch?('n')
end
def build_head?
include? '--HEAD'