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}) )
|
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
|
versions)
|
||||||
|
local opts=$([[ "${COMP_WORDS[*]}" =~ "--compact" ]] || echo "--compact")
|
||||||
|
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
|
||||||
|
return
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -272,10 +272,13 @@ For the full command list, see the COMMANDS section.
|
|||||||
|
|
||||||
If `--installed` is passed, only list installed formulae.
|
If `--installed` is passed, only list installed formulae.
|
||||||
|
|
||||||
* `versions` <formulae>:
|
* `versions [--compact]` <formulae>:
|
||||||
List previous versions of <formulae>, along with a command to checkout
|
List previous versions of <formulae>, along with a command to checkout
|
||||||
each version.
|
each version.
|
||||||
|
|
||||||
|
If `--compact` is passed, show all options on a single line separated by
|
||||||
|
spaces.
|
||||||
|
|
||||||
* `--cache`:
|
* `--cache`:
|
||||||
Display Homebrew's download cache. *Default:* `~/Library/Caches/Homebrew`
|
Display Homebrew's download cache. *Default:* `~/Library/Caches/Homebrew`
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,9 @@ module Homebrew extend self
|
|||||||
raise "Please `brew install git` first" unless system "/usr/bin/which -s git"
|
raise "Please `brew install git` first" unless system "/usr/bin/which -s git"
|
||||||
|
|
||||||
ARGV.formulae.all? do |f|
|
ARGV.formulae.all? do |f|
|
||||||
|
if ARGV.include? '--compact'
|
||||||
|
puts f.versions * " "
|
||||||
|
else
|
||||||
f.versions do |version, sha|
|
f.versions do |version, sha|
|
||||||
print Tty.white
|
print Tty.white
|
||||||
print "#{version.ljust(8)} "
|
print "#{version.ljust(8)} "
|
||||||
@ -13,6 +16,7 @@ module Homebrew extend self
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -55,14 +59,10 @@ class Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
def version_for_sha sha
|
def version_for_sha sha
|
||||||
begin
|
mktemp do
|
||||||
version = mktemp do
|
|
||||||
path = Pathname.new(Pathname.pwd+"#{name}.rb")
|
path = Pathname.new(Pathname.pwd+"#{name}.rb")
|
||||||
path.write text_from_sha(sha)
|
path.write text_from_sha(sha)
|
||||||
Formula.factory(path).version
|
Formula.factory(path).version
|
||||||
end
|
end rescue nil
|
||||||
rescue
|
|
||||||
opoo "Version of #{name} could not be determined for #{sha}."
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
.\" generated with Ronn/v0.7.3
|
.\" generated with Ronn/v0.7.3
|
||||||
.\" http://github.com/rtomayko/ronn/tree/0.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"
|
.SH "NAME"
|
||||||
\fBbrew\fR \- The missing package manager for OS X
|
\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\.
|
If \fB\-\-installed\fR is passed, only list installed formulae\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBversions\fR \fIformulae\fR
|
\fBversions [\-\-compact]\fR \fIformulae\fR
|
||||||
List previous versions of \fIformulae\fR, along with a command to checkout each version\.
|
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
|
.TP
|
||||||
\fB\-\-cache\fR
|
\fB\-\-cache\fR
|
||||||
Display Homebrew\'s download cache\. \fIDefault:\fR \fB~/Library/Caches/Homebrew\fR
|
Display Homebrew\'s download cache\. \fIDefault:\fR \fB~/Library/Caches/Homebrew\fR
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user