Merge pull request #5478 from MikeMcQuaid/info-json-default

info: make --json a valid argument.
This commit is contained in:
Mike McQuaid 2019-01-04 13:42:09 +00:00 committed by GitHub
commit 930f7b90dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 14 deletions

View File

@ -24,9 +24,9 @@
#: #:
#: To view formula history locally: `brew log -p` <formula> #: To view formula history locally: `brew log -p` <formula>
#: #:
#: * `info` `--json=`<version> (`--all`|`--installed`|<formulae>): #: * `info` `--json[=`<version>] (`--all`|`--installed`|<formulae>):
#: Print a JSON representation of <formulae>. Currently the only accepted value #: Print a JSON representation of <formulae>. Currently the default and
#: for <version> is `v1`. #: only accepted value for <version> is `v1`.
#: #:
#: Pass `--all` to get information on all formulae, or `--installed` to get #: Pass `--all` to get information on all formulae, or `--installed` to get
#: information on all installed formulae. #: information on all installed formulae.
@ -66,8 +66,8 @@ module Homebrew
switch "--github", switch "--github",
description: "Open a browser to the GitHub History page for provided <formula>. "\ description: "Open a browser to the GitHub History page for provided <formula>. "\
"To view formula history locally: `brew log -p` <formula>" "To view formula history locally: `brew log -p` <formula>"
flag "--json=", flag "--json",
description: "Print a JSON representation of <formulae>. Currently the only accepted "\ description: "Print a JSON representation of <formulae>. Currently the default and only accepted "\
"value for <version> is `v1`. See the docs for examples of using the JSON "\ "value for <version> is `v1`. See the docs for examples of using the JSON "\
"output: <https://docs.brew.sh/Querying-Brew>" "output: <https://docs.brew.sh/Querying-Brew>"
switch "--all", switch "--all",
@ -84,10 +84,12 @@ module Homebrew
def info def info
info_args.parse info_args.parse
# eventually we'll solidify an API, but we'll keep old versions if args.json
# awhile around for compatibility if args.json == "v1" || args.json == true
if args.json == "v1"
print_json print_json
else
raise UsageError, "invalid JSON version: #{args.json}"
end
elsif args.github? elsif args.github?
exec_browser(*ARGV.formulae.map { |f| github_info(f) }) exec_browser(*ARGV.formulae.map { |f| github_info(f) })
else else

View File

@ -226,9 +226,9 @@ these flags should only appear after a command.
To view formula history locally: `brew log -p` *`formula`* To view formula history locally: `brew log -p` *`formula`*
* `info` `--json=`*`version`* (`--all`|`--installed`|*`formulae`*): * `info` `--json[=`*`version`*] (`--all`|`--installed`|*`formulae`*):
Print a JSON representation of *`formulae`*. Currently the only accepted value Print a JSON representation of *`formulae`*. Currently the default and
for *`version`* is `v1`. only accepted value for *`version`* is `v1`.
Pass `--all` to get information on all formulae, or `--installed` to get Pass `--all` to get information on all formulae, or `--installed` to get
information on all installed formulae. information on all installed formulae.

View File

@ -238,8 +238,8 @@ Open a browser to the GitHub History page for \fIformula\fR\.
To view formula history locally: \fBbrew log \-p\fR \fIformula\fR To view formula history locally: \fBbrew log \-p\fR \fIformula\fR
. .
.TP .TP
\fBinfo\fR \fB\-\-json=\fR\fIversion\fR (\fB\-\-all\fR|\fB\-\-installed\fR|\fIformulae\fR) \fBinfo\fR \fB\-\-json[=\fR\fIversion\fR] (\fB\-\-all\fR|\fB\-\-installed\fR|\fIformulae\fR)
Print a JSON representation of \fIformulae\fR\. Currently the only accepted value for \fIversion\fR is \fBv1\fR\. Print a JSON representation of \fIformulae\fR\. Currently the default and only accepted value for \fIversion\fR is \fBv1\fR\.
. .
.IP .IP
Pass \fB\-\-all\fR to get information on all formulae, or \fB\-\-installed\fR to get information on all installed formulae\. Pass \fB\-\-all\fR to get information on all formulae, or \fB\-\-installed\fR to get information on all installed formulae\.