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>
This commit is contained in:
parent
016a508c7a
commit
f3f04e595d
@ -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
|
||||
|
||||
|
||||
@ -272,10 +272,13 @@ For the full command list, see the COMMANDS section.
|
||||
|
||||
If `--installed` is passed, only list installed formulae.
|
||||
|
||||
* `versions` <formulae>:
|
||||
* `versions [--compact]` <formulae>:
|
||||
List previous versions of <formulae>, 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`
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user