Port Homebrew::Cmd::TapInfo

This commit is contained in:
Douglas Eichelberger 2024-04-01 10:15:28 -07:00
parent 5495ff1eea
commit be42d46d49
2 changed files with 77 additions and 76 deletions

View File

@ -1,14 +1,12 @@
# typed: true
# frozen_string_literal: true
require "cli/parser"
require "abstract_command"
module Homebrew
module_function
sig { returns(CLI::Parser) }
def tap_info_args
Homebrew::CLI::Parser.new do
module Cmd
class TapInfo < AbstractCommand
cmd_args do
description <<~EOS
Show detailed information about one or more <tap>s.
If no <tap> names are provided, display brief statistics for all installed taps.
@ -22,11 +20,9 @@ module Homebrew
named_args :tap
end
end
def tap_info
args = tap_info_args.parse
sig { override.void }
def run
taps = if args.installed?
Tap
else
@ -42,6 +38,8 @@ module Homebrew
end
end
private
def print_tap_info(taps)
if taps.none?
tap_count = 0
@ -86,3 +84,5 @@ module Homebrew
puts JSON.pretty_generate(taps.map(&:to_hash))
end
end
end
end

View File

@ -1,8 +1,9 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
require "cmd/tap-info"
RSpec.describe "brew tap-info" do
RSpec.describe Homebrew::Cmd::TapInfo do
it_behaves_like "parseable arguments"
it "gets information for a given Tap", :integration_test, :needs_network do