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
require "cli/parser"
require "abstract_command"
module Homebrew
module_function
sig { returns(CLI::Parser) }
def tap_args
Homebrew::CLI::Parser.new do
module Cmd
class TapCmd < AbstractCommand
cmd_args do
usage_banner "`tap` [<options>] [<user>`/`<repo>] [<URL>]"
description <<~EOS
Tap a formula repository.
@ -30,7 +28,8 @@ module Homebrew
replacement: false,
disable: true
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,
disable: true
switch "--[no-]force-auto-update",
@ -47,12 +46,9 @@ module Homebrew
named_args :tap, max: 2
end
end
sig { void }
def tap
args = tap_args.parse
sig { override.void }
def run
if args.repair?
Tap.installed.each do |tap|
tap.link_completions_and_manpages
@ -75,4 +71,6 @@ module Homebrew
end
end
end
end
end
end

View File

@ -1,8 +1,9 @@
# frozen_string_literal: true
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 "taps a given Tap", :integration_test do