Port Homebrew::Cmd::Repository
This commit is contained in:
parent
6a1d43337c
commit
3f856f6516
@ -1,14 +1,15 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cli/parser"
|
||||
require "abstract_command"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
module Cmd
|
||||
class Repository < AbstractCommand
|
||||
sig { override.returns(String) }
|
||||
def self.command_name = "--repository"
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def __repository_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Display where Homebrew's Git repository is located.
|
||||
|
||||
@ -17,16 +18,15 @@ module Homebrew
|
||||
|
||||
named_args :tap
|
||||
end
|
||||
end
|
||||
|
||||
sig { void }
|
||||
def __repository
|
||||
args = __repository_args.parse
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
if args.no_named?
|
||||
puts HOMEBREW_REPOSITORY
|
||||
else
|
||||
puts args.named.to_taps.map(&:path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/--repository"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe "brew --repository" do
|
||||
RSpec.describe Homebrew::Cmd::Repository do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "prints Homebrew's repository", :integration_test do
|
||||
|
Loading…
x
Reference in New Issue
Block a user