Merge pull request #5293 from GauthamGoli/tap-info-args

tap-info: Use CLI::Parser to parse args
This commit is contained in:
Gautham Goli 2018-11-11 10:53:05 +05:30 committed by GitHub
commit 32310153f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,11 +15,33 @@
#: See the docs for examples of using the JSON output: #: See the docs for examples of using the JSON output:
#: <https://docs.brew.sh/Querying-Brew> #: <https://docs.brew.sh/Querying-Brew>
require "cli_parser"
module Homebrew module Homebrew
module_function module_function
def tap_info_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`tap-info` [<options>] [<taps>]
Display detailed information about one or more provided <taps>.
Display a brief summary of all installed taps if no <taps> are passed.
EOS
switch "--installed",
description: "Display information on all installed taps."
flag "--json=",
description: "Print a JSON representation of <taps>. Currently the only accepted value for "\
"<version> is `v1`. See the docs for examples of using the JSON output: "\
"<https://docs.brew.sh/Querying-Brew>"
switch :debug
end
end
def tap_info def tap_info
if ARGV.include? "--installed" tap_info_args.parse
if args.installed?
taps = Tap taps = Tap
else else
taps = ARGV.named.sort.map do |name| taps = ARGV.named.sort.map do |name|
@ -27,7 +49,7 @@ module Homebrew
end end
end end
if ARGV.json == "v1" if args.json == "v1"
print_tap_json(taps.sort_by(&:to_s)) print_tap_json(taps.sort_by(&:to_s))
else else
print_tap_info(taps.sort_by(&:to_s)) print_tap_info(taps.sort_by(&:to_s))