Port Homebrew::Cmd::Cellar

This commit is contained in:
Douglas Eichelberger 2024-04-01 15:56:06 -07:00
parent 102051c35d
commit 754151fcb8
3 changed files with 25 additions and 23 deletions

View File

@ -6,7 +6,6 @@ require "abstract_command"
module Homebrew module Homebrew
module Cmd module Cmd
class Caskroom < AbstractCommand class Caskroom < AbstractCommand
sig { override.returns(String) } sig { override.returns(String) }
def self.command_name = "--caskroom" def self.command_name = "--caskroom"

View File

@ -1,13 +1,15 @@
# 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 Cellar < AbstractCommand
sig { override.returns(String) }
def self.command_name = "--cellar"
def __cellar_args cmd_args do
Homebrew::CLI::Parser.new do
description <<~EOS description <<~EOS
Display Homebrew's Cellar path. *Default:* `$(brew --prefix)/Cellar`, or if Display Homebrew's Cellar path. *Default:* `$(brew --prefix)/Cellar`, or if
that directory doesn't exist, `$(brew --repository)/Cellar`. that directory doesn't exist, `$(brew --repository)/Cellar`.
@ -18,11 +20,9 @@ module Homebrew
named_args :formula named_args :formula
end end
end
def __cellar
args = __cellar_args.parse
sig { override.void }
def run
if args.no_named? if args.no_named?
puts HOMEBREW_CELLAR puts HOMEBREW_CELLAR
else else
@ -30,3 +30,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/--cellar"
require "cmd/shared_examples/args_parse" require "cmd/shared_examples/args_parse"
RSpec.describe "brew --cellar" do RSpec.describe Homebrew::Cmd::Cellar do
it_behaves_like "parseable arguments" it_behaves_like "parseable arguments"
it "prints Homebrew's Cellar", :integration_test do it "prints Homebrew's Cellar", :integration_test do