Port Homebrew::Cmd::Cellar
This commit is contained in:
parent
102051c35d
commit
754151fcb8
@ -6,7 +6,6 @@ require "abstract_command"
|
||||
module Homebrew
|
||||
module Cmd
|
||||
class Caskroom < AbstractCommand
|
||||
|
||||
sig { override.returns(String) }
|
||||
def self.command_name = "--caskroom"
|
||||
|
||||
|
||||
@ -1,32 +1,34 @@
|
||||
# typed: true
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cli/parser"
|
||||
require "abstract_command"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
module Cmd
|
||||
class Cellar < AbstractCommand
|
||||
sig { override.returns(String) }
|
||||
def self.command_name = "--cellar"
|
||||
|
||||
def __cellar_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
description <<~EOS
|
||||
Display Homebrew's Cellar path. *Default:* `$(brew --prefix)/Cellar`, or if
|
||||
that directory doesn't exist, `$(brew --repository)/Cellar`.
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Display Homebrew's Cellar path. *Default:* `$(brew --prefix)/Cellar`, or if
|
||||
that directory doesn't exist, `$(brew --repository)/Cellar`.
|
||||
|
||||
If <formula> is provided, display the location in the Cellar where <formula>
|
||||
would be installed, without any sort of versioned directory as the last path.
|
||||
EOS
|
||||
If <formula> is provided, display the location in the Cellar where <formula>
|
||||
would be installed, without any sort of versioned directory as the last path.
|
||||
EOS
|
||||
|
||||
named_args :formula
|
||||
end
|
||||
end
|
||||
named_args :formula
|
||||
end
|
||||
|
||||
def __cellar
|
||||
args = __cellar_args.parse
|
||||
|
||||
if args.no_named?
|
||||
puts HOMEBREW_CELLAR
|
||||
else
|
||||
puts args.named.to_resolved_formulae.map(&:rack)
|
||||
sig { override.void }
|
||||
def run
|
||||
if args.no_named?
|
||||
puts HOMEBREW_CELLAR
|
||||
else
|
||||
puts args.named.to_resolved_formulae.map(&:rack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/--cellar"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe "brew --cellar" do
|
||||
RSpec.describe Homebrew::Cmd::Cellar do
|
||||
it_behaves_like "parseable arguments"
|
||||
|
||||
it "prints Homebrew's Cellar", :integration_test do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user