Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tap-info: Use CLI::Parser to parse args #5293

Merged
merged 1 commit into from
Nov 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions Library/Homebrew/cmd/tap-info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,41 @@
#: See the docs for examples of using the JSON output:
#: <https://docs.brew.sh/Querying-Brew>

require "cli_parser"

module Homebrew
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
if ARGV.include? "--installed"
tap_info_args.parse

if args.installed?
taps = Tap
else
taps = ARGV.named.sort.map do |name|
Tap.fetch(name)
end
end

if ARGV.json == "v1"
if args.json == "v1"
print_tap_json(taps.sort_by(&:to_s))
else
print_tap_info(taps.sort_by(&:to_s))
Expand Down