From 89717c9d9089de1e78e49f36fda812501ce51891 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Thu, 3 Jun 2010 15:09:20 -0700 Subject: [PATCH] Add sample external commands: dirty, leaves, options See: * http://github.com/mxcl/homebrew/issues/issue/1359 * http://github.com/mxcl/homebrew/issues/issue/1438 --- Library/Contributions/examples/brew-dirty.rb | 7 +++++++ Library/Contributions/examples/brew-leaves.rb | 9 +++++++++ Library/Contributions/examples/brew-options.rb | 9 +++++++++ 3 files changed, 25 insertions(+) create mode 100755 Library/Contributions/examples/brew-dirty.rb create mode 100755 Library/Contributions/examples/brew-leaves.rb create mode 100755 Library/Contributions/examples/brew-options.rb diff --git a/Library/Contributions/examples/brew-dirty.rb b/Library/Contributions/examples/brew-dirty.rb new file mode 100755 index 0000000000..e22ad75c67 --- /dev/null +++ b/Library/Contributions/examples/brew-dirty.rb @@ -0,0 +1,7 @@ +# See: http://github.com/mxcl/homebrew/issues/issue/1359 + +to_list = HOMEBREW_CELLAR.children.select { |pn| pn.directory? } +to_list.each do |d| + versions = d.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s } + puts "#{d.basename} (#{versions.join(', ')})" if versions.size > 1 +end diff --git a/Library/Contributions/examples/brew-leaves.rb b/Library/Contributions/examples/brew-leaves.rb new file mode 100755 index 0000000000..ba5644c555 --- /dev/null +++ b/Library/Contributions/examples/brew-leaves.rb @@ -0,0 +1,9 @@ +# See: http://github.com/mxcl/homebrew/issues/issue/1438 + +require 'formula' +deps_graph = Formula.get_used_by +formulas = HOMEBREW_CELLAR.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s } +formulas.each do |name| + deps = deps_graph[name] || [] + puts name if !deps.any? { |dep| formulas.include?(dep) } +end diff --git a/Library/Contributions/examples/brew-options.rb b/Library/Contributions/examples/brew-options.rb new file mode 100755 index 0000000000..bf7a0180a2 --- /dev/null +++ b/Library/Contributions/examples/brew-options.rb @@ -0,0 +1,9 @@ +ARGV.formulae.each do |f| + f.options rescue next + puts f.name + f.options.each do |o| + puts o[0] + puts "\t"+o[1] + end + puts +end