Port Homebrew::Cmd::TapInfo
This commit is contained in:
parent
5495ff1eea
commit
be42d46d49
@ -1,14 +1,12 @@
|
|||||||
# typed: true
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "abstract_command"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module Cmd
|
||||||
|
class TapInfo < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def tap_info_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Show detailed information about one or more <tap>s.
|
Show detailed information about one or more <tap>s.
|
||||||
If no <tap> names are provided, display brief statistics for all installed taps.
|
If no <tap> names are provided, display brief statistics for all installed taps.
|
||||||
@ -22,11 +20,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :tap
|
named_args :tap
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def tap_info
|
|
||||||
args = tap_info_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
taps = if args.installed?
|
taps = if args.installed?
|
||||||
Tap
|
Tap
|
||||||
else
|
else
|
||||||
@ -42,6 +38,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def print_tap_info(taps)
|
def print_tap_info(taps)
|
||||||
if taps.none?
|
if taps.none?
|
||||||
tap_count = 0
|
tap_count = 0
|
||||||
@ -86,3 +84,5 @@ module Homebrew
|
|||||||
puts JSON.pretty_generate(taps.map(&:to_hash))
|
puts JSON.pretty_generate(taps.map(&:to_hash))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cmd/shared_examples/args_parse"
|
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_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "gets information for a given Tap", :integration_test, :needs_network do
|
it "gets information for a given Tap", :integration_test, :needs_network do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user