aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Vandenberg2014-05-16 08:47:09 -0700
committerAdam Vandenberg2014-05-16 09:03:12 -0700
commitb629390ce5940a9c1e2c6e7ca7227b523767e358 (patch)
tree7d4325f64a7169f05e7c6cc1aad0ef371224fe35
parenta7f7ce8237fba82507f66a67a214481ba9e707a6 (diff)
downloadhomebrew-b629390ce5940a9c1e2c6e7ca7227b523767e358.tar.bz2
add --installed to json info
Closes #29315.
-rw-r--r--Library/Contributions/brew_bash_completion.sh2
-rw-r--r--Library/Contributions/manpages/brew.1.md5
-rw-r--r--Library/Homebrew/cmd/info.rb10
-rw-r--r--Library/Homebrew/formula.rb1
-rw-r--r--share/man/man1/brew.15
5 files changed, 18 insertions, 5 deletions
diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh
index 61c81361f..7d3fc595f 100644
--- a/Library/Contributions/brew_bash_completion.sh
+++ b/Library/Contributions/brew_bash_completion.sh
@@ -222,7 +222,7 @@ _brew_info ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
- __brewcomp "--all --github --json=v1"
+ __brewcomp "--all --github --installed --json=v1"
return
;;
esac
diff --git a/Library/Contributions/manpages/brew.1.md b/Library/Contributions/manpages/brew.1.md
index 563d072c2..21b839917 100644
--- a/Library/Contributions/manpages/brew.1.md
+++ b/Library/Contributions/manpages/brew.1.md
@@ -160,10 +160,13 @@ Note that these flags should only appear after a command.
To view formula history locally: `brew log -p <formula>`.
- * `info --json=<version>` <formula>:
+ * `info --json=<version>` (--all|--installed|<formula>):
Print a JSON representation of <formula>. Currently the only accepted value
for <version> is `v1`.
+ Pass `--all` to get information on all formulae, or `--installed` to get
+ information on all installed formulae.
+
* `install [--debug] [--env=<std|super>] [--ignore-dependencies] [--only-dependencies] [--cc=<compiler>] [--build-from-source] [--devel|--HEAD]` <formula>:
Install <formula>.
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index 9deda9dfb..ef8e2ac52 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -41,8 +41,14 @@ module Homebrew extend self
end
def print_json
- formulae = ARGV.include?("--all") ? Formula : ARGV.formulae
- json = formulae.map {|f| f.to_hash}
+ ff = if ARGV.include? "--all"
+ Formula
+ elsif ARGV.include? "--installed"
+ Formula.installed
+ else
+ ARGV.formulae
+ end
+ json = ff.map {|f| f.to_hash}
if json.size == 1
puts Utils::JSON.dump(json.pop)
else
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index d6a6f60e1..f0217bb74 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -369,6 +369,7 @@ class Formula
include Enumerable
end
+ # An array of all installed formulae
def self.installed
return [] unless HOMEBREW_CELLAR.directory?
diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1
index 6ec2986b0..0632160d6 100644
--- a/share/man/man1/brew.1
+++ b/share/man/man1/brew.1
@@ -177,9 +177,12 @@ Open a browser to the GitHub History page for formula \fIformula\fR\.
To view formula history locally: \fBbrew log \-p <formula>\fR\.
.
.TP
-\fBinfo \-\-json=<version>\fR \fIformula\fR
+\fBinfo \-\-json=<version>\fR (\-\-all|\-\-installed|\fIformula\fR)
Print a JSON representation of \fIformula\fR\. Currently the only accepted value for \fIversion\fR is \fBv1\fR\.
.
+.IP
+Pass \fB\-\-all\fR to get information on all formulae, or \fB\-\-installed\fR to get information on all installed formulae\.
+.
.TP
\fBinstall [\-\-debug] [\-\-env=<std|super>] [\-\-ignore\-dependencies] [\-\-only\-dependencies] [\-\-cc=<compiler>] [\-\-build\-from\-source] [\-\-devel|\-\-HEAD]\fR \fIformula\fR
Install \fIformula\fR\.