From e3a178add231526c388cba179fcea9bb3c30bf26 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 4 Jan 2019 13:26:16 +0000 Subject: [PATCH] info: make --json a valid argument. This is already accepted so let's handle this in the logic instead. --- Library/Homebrew/cmd/info.rb | 20 +++++++++++--------- docs/Manpage.md | 6 +++--- manpages/brew.1 | 4 ++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 3a5329b8e6..4f092c4682 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -24,9 +24,9 @@ #: #: To view formula history locally: `brew log -p` #: -#: * `info` `--json=` (`--all`|`--installed`|): -#: Print a JSON representation of . Currently the only accepted value -#: for is `v1`. +#: * `info` `--json[=`] (`--all`|`--installed`|): +#: Print a JSON representation of . Currently the default and +#: only accepted value for is `v1`. #: #: Pass `--all` to get information on all formulae, or `--installed` to get #: information on all installed formulae. @@ -66,8 +66,8 @@ module Homebrew switch "--github", description: "Open a browser to the GitHub History page for provided . "\ "To view formula history locally: `brew log -p` " - flag "--json=", - description: "Print a JSON representation of . Currently the only accepted "\ + flag "--json", + description: "Print a JSON representation of . Currently the default and only accepted "\ "value for is `v1`. See the docs for examples of using the JSON "\ "output: " switch "--all", @@ -84,10 +84,12 @@ module Homebrew def info info_args.parse - # eventually we'll solidify an API, but we'll keep old versions - # awhile around for compatibility - if args.json == "v1" - print_json + if args.json + if args.json == "v1" || args.json == true + print_json + else + raise UsageError, "invalid JSON version: #{args.json}" + end elsif args.github? exec_browser(*ARGV.formulae.map { |f| github_info(f) }) else diff --git a/docs/Manpage.md b/docs/Manpage.md index 590b4c7552..1dafa94a03 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -226,9 +226,9 @@ these flags should only appear after a command. To view formula history locally: `brew log -p` *`formula`* - * `info` `--json=`*`version`* (`--all`|`--installed`|*`formulae`*): - Print a JSON representation of *`formulae`*. Currently the only accepted value - for *`version`* is `v1`. + * `info` `--json[=`*`version`*] (`--all`|`--installed`|*`formulae`*): + Print a JSON representation of *`formulae`*. Currently the default and + only accepted value for *`version`* is `v1`. Pass `--all` to get information on all formulae, or `--installed` to get information on all installed formulae. diff --git a/manpages/brew.1 b/manpages/brew.1 index 4d344e7288..c3c194663d 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -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 . .TP -\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\. +\fBinfo\fR \fB\-\-json[=\fR\fIversion\fR] (\fB\-\-all\fR|\fB\-\-installed\fR|\fIformulae\fR) +Print a JSON representation of \fIformulae\fR\. Currently the default and 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\.