From e9b2a7fed3defe5ba7bd38b095edfc2563f9aca3 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Sat, 10 Nov 2018 22:45:32 +0530 Subject: [PATCH] tap-info: Use CLI::Parser to parse args --- Library/Homebrew/cmd/tap-info.rb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/tap-info.rb b/Library/Homebrew/cmd/tap-info.rb index 082deb611d..e0cbba78d1 100644 --- a/Library/Homebrew/cmd/tap-info.rb +++ b/Library/Homebrew/cmd/tap-info.rb @@ -15,11 +15,33 @@ #: See the docs for examples of using the JSON output: #: +require "cli_parser" + module Homebrew module_function + def tap_info_args + Homebrew::CLI::Parser.new do + usage_banner <<~EOS + `tap-info` [] [] + + Display detailed information about one or more provided . + Display a brief summary of all installed taps if no are passed. + EOS + switch "--installed", + description: "Display information on all installed taps." + flag "--json=", + description: "Print a JSON representation of . Currently the only accepted value for "\ + " is `v1`. See the docs for examples of using the JSON output: "\ + "" + 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| @@ -27,7 +49,7 @@ module Homebrew 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))