diff options
| author | Jack Nagel | 2012-01-06 14:35:48 -0600 |
|---|---|---|
| committer | Jack Nagel | 2012-01-06 14:51:15 -0600 |
| commit | b26e66fa465c06ba1968bbef4ba3f8f0a27f637c (patch) | |
| tree | ff9986ff62a39c95e15dba7e5f2de7cbb0f9582e /Library/Homebrew/cmd | |
| parent | 49bb7b65a5a3e93a97e0ecd0f5eab08f02114f49 (diff) | |
| download | homebrew-b26e66fa465c06ba1968bbef4ba3f8f0a27f637c.tar.bz2 | |
versions: enable '--compact' output
This will be useful for shell tab completion when something like `brew
install <formula> --version <version>` is implemented.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/versions.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index bd234d843..906fc4f8c 100644 --- a/Library/Homebrew/cmd/versions.rb +++ b/Library/Homebrew/cmd/versions.rb @@ -5,11 +5,15 @@ module Homebrew extend self raise "Please `brew install git` first" unless system "/usr/bin/which -s git" ARGV.formulae.all? do |f| - f.versions do |version, sha| - print Tty.white - print "#{version.ljust(8)} " - print Tty.reset - puts "git checkout #{sha} #{f.pretty_relative_path}" + if ARGV.include? '--compact' + puts f.versions * " " + else + f.versions do |version, sha| + print Tty.white + print "#{version.ljust(8)} " + print Tty.reset + puts "git checkout #{sha} #{f.pretty_relative_path}" + end end end end @@ -55,14 +59,10 @@ class Formula end def version_for_sha sha - begin - version = mktemp do - path = Pathname.new(Pathname.pwd+"#{name}.rb") - path.write text_from_sha(sha) - Formula.factory(path).version - end - rescue - opoo "Version of #{name} could not be determined for #{sha}." - end + mktemp do + path = Pathname.new(Pathname.pwd+"#{name}.rb") + path.write text_from_sha(sha) + Formula.factory(path).version + end rescue nil end end |
