diff --git a/Library/Homebrew/cmd/--caskroom.rb b/Library/Homebrew/cmd/--caskroom.rb index e3d64ec694..df2dcb34d3 100644 --- a/Library/Homebrew/cmd/--caskroom.rb +++ b/Library/Homebrew/cmd/--caskroom.rb @@ -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 is provided, display the location in the Caskroom where - 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 is provided, display the location in the Caskroom where + 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 diff --git a/Library/Homebrew/test/cmd/--caskroom_spec.rb b/Library/Homebrew/test/cmd/--caskroom_spec.rb index 58e7ac4e95..4002f17e2d 100644 --- a/Library/Homebrew/test/cmd/--caskroom_spec.rb +++ b/Library/Homebrew/test/cmd/--caskroom_spec.rb @@ -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