aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/cmd/list.rb45
1 files changed, 29 insertions, 16 deletions
diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb
index 54292f513..602396e4a 100644
--- a/Library/Homebrew/cmd/list.rb
+++ b/Library/Homebrew/cmd/list.rb
@@ -1,31 +1,44 @@
module Homebrew extend self
def list
- # Cellar doesn't until the first formula is installed.
+
+ # Use of exec means we don't explicitly exit
+ list_unbrewed if ARGV.flag? '--unbrewed'
+
+ # Unbrewed uses the PREFIX, which will exist
+ # Things below use the CELLAR, which doesn't until the first formula is installed.
return unless HOMEBREW_CELLAR.exist?
- if ARGV.flag? '--unbrewed'
- dirs = HOMEBREW_PREFIX.children.select{ |pn| pn.directory? }.map{ |pn| pn.basename.to_s }
- dirs -= %w[Library Cellar .git]
- cd HOMEBREW_PREFIX
- exec 'find', *dirs + %w[-type f ( ! -iname .ds_store ! -iname brew ! -iname brew-man.1 ! -iname brew.1 )]
- elsif ARGV.flag? '--versions'
- if ARGV.named.empty?
- HOMEBREW_CELLAR.children.select{ |pn| pn.directory? }
- else
- ARGV.named.map{ |n| HOMEBREW_CELLAR+n }.select{ |pn| pn.exist? }
- end.each do |d|
- versions = d.children.select{ |pn| pn.directory? }.map{ |pn| pn.basename.to_s }
- puts "#{d.basename} #{versions*' '}"
- end
+ if ARGV.flag? '--versions'
+ list_versions
elsif ARGV.named.empty?
ENV['CLICOLOR'] = nil
- exec 'ls', *ARGV.options_only << HOMEBREW_CELLAR if HOMEBREW_CELLAR.exist?
+ exec 'ls', *ARGV.options_only << HOMEBREW_CELLAR
elsif ARGV.verbose? or not $stdout.tty?
exec "find", *ARGV.kegs + %w[-not -type d -print]
else
ARGV.kegs.each{ |keg| PrettyListing.new keg }
end
end
+
+private
+
+ def list_unbrewed
+ dirs = HOMEBREW_PREFIX.children.select{ |pn| pn.directory? }.map{ |pn| pn.basename.to_s }
+ dirs -= %w[Library Cellar .git]
+ cd HOMEBREW_PREFIX
+ exec 'find', *dirs + %w[-type f ( ! -iname .ds_store ! -iname brew ! -iname brew-man.1 ! -iname brew.1 )]
+ end
+
+ def list_versions
+ if ARGV.named.empty?
+ HOMEBREW_CELLAR.children.select{ |pn| pn.directory? }
+ else
+ ARGV.named.map{ |n| HOMEBREW_CELLAR+n }.select{ |pn| pn.exist? }
+ end.each do |d|
+ versions = d.children.select{ |pn| pn.directory? }.map{ |pn| pn.basename.to_s }
+ puts "#{d.basename} #{versions*' '}"
+ end
+ end
end
class PrettyListing