Skip to content

Commit

Permalink
Port Homebrew::Cmd::Repository
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Apr 1, 2024
1 parent 6a1d433 commit 3f856f6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
40 changes: 20 additions & 20 deletions Library/Homebrew/cmd/--repository.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# 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
description <<~EOS
Display where Homebrew's Git repository is located.
cmd_args do
description <<~EOS
Display where Homebrew's Git repository is located.
If <user>`/`<repo> are provided, display where tap <user>`/`<repo>'s directory is located.
EOS
If <user>`/`<repo> are provided, display where tap <user>`/`<repo>'s directory is located.
EOS

named_args :tap
end
end

sig { void }
def __repository
args = __repository_args.parse
named_args :tap
end

if args.no_named?
puts HOMEBREW_REPOSITORY
else
puts args.named.to_taps.map(&:path)
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
3 changes: 2 additions & 1 deletion Library/Homebrew/test/cmd/--repository_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 3f856f6

Please sign in to comment.