Don't throw if named.empty?

Generally this isn't desired or useful.
This commit is contained in:
Max Howell 2009-10-26 18:20:18 +00:00
parent 794a55a72b
commit 03ca3e24d0
2 changed files with 11 additions and 15 deletions

View File

@ -23,11 +23,7 @@
#
module HomebrewArgvExtension
def named
raise UsageError if private_named.empty?
private_named
end
def named_empty?
private_named.empty?
@named ||= reject{|arg| arg[0..0] == '-'}
end
def options
select {|arg| arg[0..0] == '-'}
@ -108,15 +104,13 @@ Commands useful when contributing:
To visit the Homebrew homepage type:
brew home
EOS
EOS
end
private
def private_named
@named ||= reject{|arg| arg[0..0] == '-'}
end
private
def downcased_unique_named
@downcased_unique_named ||= private_named.collect{|arg| arg.downcase}.uniq
@downcased_unique_named ||= named.collect{|arg| arg.downcase}.uniq
end
end

View File

@ -80,7 +80,7 @@ begin
dump_config
when 'home', 'homepage'
if ARGV.named_empty?
if ARGV.named.empty?
exec "open", HOMEBREW_WWW
else
exec "open", *ARGV.formulae.collect {|f| f.homepage}
@ -92,7 +92,7 @@ begin
dirs -= ['Library', 'Cellar', '.git']
Dir.chdir HOMEBREW_PREFIX
exec 'find', *dirs + %w[-type f ( ! -iname .ds_store ! -iname brew )]
elsif ARGV.named_empty?
elsif ARGV.named.empty?
ENV['CLICOLOR']=nil
exec 'ls', *ARGV.options<<HOMEBREW_CELLAR if HOMEBREW_CELLAR.exist?
elsif ARGV.verbose? or not $stdout.tty?
@ -110,7 +110,7 @@ begin
end
when 'edit'
if ARGV.named_empty?
if ARGV.named.empty?
# EDITOR isn't a good fit here, we need a GUI client that actually has
# a UI for projects, so apologies if this wasn't what you expected,
# please improve it! :)
@ -163,6 +163,8 @@ begin
when 'create'
if ARGV.include? '--macports'
exec "open", "http://www.macports.org/ports.php?by=name&substr=#{ARGV.next}"
elsif ARGV.named.empty?
raise UsageError
else
exec_editor *ARGV.named.collect {|name| make name}
end
@ -171,7 +173,7 @@ begin
puts diy
when 'info', 'abv'
if ARGV.named_empty?
if ARGV.named.empty?
puts `ls #{HOMEBREW_CELLAR} | wc -l`.strip+" kegs, "+HOMEBREW_CELLAR.abv
elsif ARGV[0][0..6] == 'http://'
puts Pathname.new(ARGV.shift).version