Port Homebrew::Cmd::Caskroom

This commit is contained in:
Douglas Eichelberger 2024-04-01 15:53:44 -07:00
parent 7bbf0a3206
commit 102051c35d
2 changed files with 25 additions and 21 deletions

View File

@ -1,32 +1,35 @@
# typed: strict
# frozen_string_literal: true
require "abstract_command"
module Homebrew
module_function
module Cmd
class Caskroom < AbstractCommand
sig { returns(CLI::Parser) }
def __caskroom_args
Homebrew::CLI::Parser.new do
description <<~EOS
Display Homebrew's Caskroom path.
sig { override.returns(String) }
def self.command_name = "--caskroom"
If <cask> is provided, display the location in the Caskroom where <cask>
would be installed, without any sort of versioned directory as the last path.
EOS
cmd_args do
description <<~EOS
Display Homebrew's Caskroom path.
named_args :cask
end
end
If <cask> is provided, display the location in the Caskroom where <cask>
would be installed, without any sort of versioned directory as the last path.
EOS
sig { void }
def __caskroom
args = __caskroom_args.parse
named_args :cask
end
if args.named.to_casks.blank?
puts Cask::Caskroom.path
else
args.named.to_casks.each do |cask|
puts "#{Cask::Caskroom.path}/#{cask.token}"
sig { override.void }
def run
if args.named.to_casks.blank?
puts Cask::Caskroom.path
else
args.named.to_casks.each do |cask|
puts "#{Cask::Caskroom.path}/#{cask.token}"
end
end
end
end
end

View File

@ -1,8 +1,9 @@
# frozen_string_literal: true
require "cmd/--caskroom"
require "cmd/shared_examples/args_parse"
RSpec.describe "brew --caskroom" do
RSpec.describe Homebrew::Cmd::Caskroom do
it_behaves_like "parseable arguments"
it "prints Homebrew's Caskroom", :integration_test do