Port Homebrew::Cmd::Tap

This commit is contained in:
Douglas Eichelberger 2024-04-01 11:42:17 -07:00
parent be42d46d49
commit 841cfd9fdc
2 changed files with 66 additions and 67 deletions

View File

@ -1,14 +1,12 @@
# typed: true # typed: strict
# frozen_string_literal: true # frozen_string_literal: true
require "cli/parser" require "abstract_command"
module Homebrew module Homebrew
module_function module Cmd
class TapCmd < AbstractCommand
sig { returns(CLI::Parser) } cmd_args do
def tap_args
Homebrew::CLI::Parser.new do
usage_banner "`tap` [<options>] [<user>`/`<repo>] [<URL>]" usage_banner "`tap` [<options>] [<user>`/`<repo>] [<URL>]"
description <<~EOS description <<~EOS
Tap a formula repository. Tap a formula repository.
@ -30,7 +28,8 @@ module Homebrew
replacement: false, replacement: false,
disable: true disable: true
switch "--shallow", switch "--shallow",
description: "Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration.", description: "Fetch tap as a shallow clone rather than a full clone. Useful for continuous " \
"integration.",
replacement: false, replacement: false,
disable: true disable: true
switch "--[no-]force-auto-update", switch "--[no-]force-auto-update",
@ -47,12 +46,9 @@ module Homebrew
named_args :tap, max: 2 named_args :tap, max: 2
end end
end
sig { void }
def tap
args = tap_args.parse
sig { override.void }
def run
if args.repair? if args.repair?
Tap.installed.each do |tap| Tap.installed.each do |tap|
tap.link_completions_and_manpages tap.link_completions_and_manpages
@ -76,3 +72,5 @@ module Homebrew
end end
end end
end end
end
end

View File

@ -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"
RSpec.describe "brew tap" do RSpec.describe Homebrew::Cmd::TapCmd do
it_behaves_like "parseable arguments" it_behaves_like "parseable arguments"
it "taps a given Tap", :integration_test do it "taps a given Tap", :integration_test do