diff options
| author | Max Howell | 2009-09-24 21:46:04 +0100 |
|---|---|---|
| committer | Max Howell | 2009-09-24 22:38:42 +0100 |
| commit | bab6515668a0e7fd34bea13c5dcc14c46a548562 (patch) | |
| tree | cf409bb6e176de75794f09cae02663ec519b7919 /Library | |
| parent | bfb3e1bfe0e3a75a97536a8e2b178f0be4ca78a6 (diff) | |
| download | brew-bab6515668a0e7fd34bea13c5dcc14c46a548562.tar.bz2 | |
Summarised listings with brew list
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.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/brew.h.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index 8878a72b3..535e3178d 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -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 |
