diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh index 355d6443f8..8299ef9a9f 100644 --- a/Library/Contributions/brew_bash_completion.sh +++ b/Library/Contributions/brew_bash_completion.sh @@ -197,6 +197,11 @@ _brew_to_completion() COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) return ;; + versions) + local opts=$([[ "${COMP_WORDS[*]}" =~ "--compact" ]] || echo "--compact") + COMPREPLY=( $(compgen -W "$opts" -- ${cur}) ) + return + ;; esac fi diff --git a/Library/Contributions/manpages/brew.1.md b/Library/Contributions/manpages/brew.1.md index 2293b60f61..66fb3eb412 100644 --- a/Library/Contributions/manpages/brew.1.md +++ b/Library/Contributions/manpages/brew.1.md @@ -272,10 +272,13 @@ For the full command list, see the COMMANDS section. If `--installed` is passed, only list installed formulae. - * `versions` : + * `versions [--compact]` : List previous versions of , along with a command to checkout each version. + If `--compact` is passed, show all options on a single line separated by + spaces. + * `--cache`: Display Homebrew's download cache. *Default:* `~/Library/Caches/Homebrew` diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index bd234d8439..906fc4f8c5 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 diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1 index 93009e2427..c2774aced0 100644 --- a/share/man/man1/brew.1 +++ b/share/man/man1/brew.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW" "1" "December 2011" "Homebrew" "brew" +.TH "BREW" "1" "January 2012" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The missing package manager for OS X @@ -304,9 +304,12 @@ Show the formulas that specify \fIformula\fR as a dependency\. The list is not r If \fB\-\-installed\fR is passed, only list installed formulae\. . .TP -\fBversions\fR \fIformulae\fR +\fBversions [\-\-compact]\fR \fIformulae\fR List previous versions of \fIformulae\fR, along with a command to checkout each version\. . +.IP +If \fB\-\-compact\fR is passed, show all options on a single line separated by spaces\. +. .TP \fB\-\-cache\fR Display Homebrew\'s download cache\. \fIDefault:\fR \fB~/Library/Caches/Homebrew\fR