Skip to content

Commit

Permalink
Summarised listings with brew list
Browse files Browse the repository at this point in the history
I'm trying to only show the interesting stuff. You can see a full listing with
brew -v list, or by piping to other commands.

Tell me if you hate it or love it.
  • Loading branch information
mxcl committed Sep 24, 2009
1 parent 9433168 commit e698609
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
61 changes: 61 additions & 0 deletions Library/Homebrew/brew.h.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,67 @@ def fix_PATH
end
ENV['PATH'] = paths*':'
end
########################################################## class PrettyListing
class PrettyListing
def initialize path
Pathname.new(path).children.sort{ |a,b| a.to_s.downcase <=> b.to_s.downcase }.each do |pn|
case pn.basename.to_s
when 'bin', 'sbin'
pn.find { |pnn| puts pnn unless pnn.directory? }
when 'lib'
print_dir pn do |pnn|
# dylibs have multiple symlinks and we don't care about them
(pnn.extname == '.dylib' or pnn.extname == '.pc') and not pnn.symlink?
end
else
print_dir pn
end
end
end
private
def print_dir root
return unless root.directory?
dirs = []
remaining_root_files = []
other = ''
root.children.sort.each do |pn|
if pn.directory?
dirs << pn
elsif block_given? and yield pn
puts pn
other = 'other '
else
remaining_root_files << pn
end
end
dirs.each do |d|
files = []
d.find { |pn| files << pn unless pn.directory? }
print_remaining_files files, d
end
print_remaining_files remaining_root_files, root, other
end
def print_remaining_files files, root, other = ''
case files.length
when 0
# noop
when 1
puts *files
else
puts "#{root} (#{files.length} #{other}files)"
end
end
end
################################################################ class Cleaner
class Cleaner
def initialize f
Expand Down
4 changes: 3 additions & 1 deletion bin/brew
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ begin
if ARGV.named_empty?
ENV['CLICOLOR']=nil
exec 'ls', *ARGV.options<<HOMEBREW_CELLAR
else
elsif ARGV.verbose?
exec "find", *ARGV.kegs+%w[-not -type d -print]
else
ARGV.kegs.each { |keg| PrettyListing.new keg }
end

when 'search', '-S'
Expand Down

0 comments on commit e698609

Please sign in to comment.