diff --git a/Library/Homebrew/cask/cmd/audit.rb b/Library/Homebrew/cask/cmd/audit.rb index 6326446fcf..80fadd1fe9 100644 --- a/Library/Homebrew/cask/cmd/audit.rb +++ b/Library/Homebrew/cask/cmd/audit.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "utils/github/actions" @@ -13,6 +13,7 @@ module Cask def self.parser super do + T.bind(self, Homebrew::CLI::Parser) switch "--[no-]download", description: "Audit the downloaded file" switch "--[no-]appcast", @@ -44,7 +45,7 @@ module Cask end casks = casks.map { |c| CaskLoader.load(c, config: Config.from_args(args)) } any_named_args = casks.any? - casks = Cask.to_a if casks.empty? + casks = Cask.all if casks.empty? results = self.class.audit_casks( *casks, diff --git a/Library/Homebrew/cask/cmd/fetch.rb b/Library/Homebrew/cask/cmd/fetch.rb index da0eb66295..784cd06f8e 100644 --- a/Library/Homebrew/cask/cmd/fetch.rb +++ b/Library/Homebrew/cask/cmd/fetch.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true module Cask @@ -11,6 +11,7 @@ module Cask def self.parser super do + T.bind(self, Homebrew::CLI::Parser) switch "--force", description: "Force redownloading even if files already exist in local cache." end diff --git a/Library/Homebrew/cask/cmd/install.rb b/Library/Homebrew/cask/cmd/install.rb index efd84d9365..11cf1f9a1d 100644 --- a/Library/Homebrew/cask/cmd/install.rb +++ b/Library/Homebrew/cask/cmd/install.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "cask_dependent" @@ -27,6 +27,7 @@ module Cask def self.parser(&block) super do + T.bind(self, Homebrew::CLI::Parser) switch "--force", description: "Force overwriting existing files." diff --git a/Library/Homebrew/cask/cmd/uninstall.rb b/Library/Homebrew/cask/cmd/uninstall.rb index 1700482a65..67be493145 100644 --- a/Library/Homebrew/cask/cmd/uninstall.rb +++ b/Library/Homebrew/cask/cmd/uninstall.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true module Cask @@ -11,6 +11,7 @@ module Cask def self.parser super do + T.bind(self, Homebrew::CLI::Parser) switch "--force", description: "Uninstall even if the is not installed, overwrite " \ "existing files and ignore errors when removing files." diff --git a/Library/Homebrew/cask/cmd/upgrade.rb b/Library/Homebrew/cask/cmd/upgrade.rb index 15dd0d6f08..134563702a 100644 --- a/Library/Homebrew/cask/cmd/upgrade.rb +++ b/Library/Homebrew/cask/cmd/upgrade.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true require "env_config" @@ -30,6 +30,7 @@ module Cask sig { returns(Homebrew::CLI::Parser) } def self.parser super do + T.bind(self, Homebrew::CLI::Parser) switch "--force", description: "Force overwriting existing files." switch "--dry-run", @@ -176,7 +177,9 @@ module Cask return true if caught_exceptions.empty? raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1 - raise caught_exceptions.first if caught_exceptions.count == 1 + raise caught_exceptions.fetch(0) if caught_exceptions.count == 1 + + false end def self.upgrade_cask( diff --git a/Library/Homebrew/cask/cmd/zap.rb b/Library/Homebrew/cask/cmd/zap.rb index b06bfa4223..31460340b2 100644 --- a/Library/Homebrew/cask/cmd/zap.rb +++ b/Library/Homebrew/cask/cmd/zap.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true module Cask @@ -11,6 +11,7 @@ module Cask def self.parser super do + T.bind(self, Homebrew::CLI::Parser) switch "--force", description: "Ignore errors when removing files." end diff --git a/Library/Homebrew/test/cask/cmd/audit_spec.rb b/Library/Homebrew/test/cask/cmd/audit_spec.rb index 1c48cc123f..27859bb32f 100644 --- a/Library/Homebrew/test/cask/cmd/audit_spec.rb +++ b/Library/Homebrew/test/cask/cmd/audit_spec.rb @@ -10,7 +10,7 @@ describe Cask::Cmd::Audit, :cask do describe "selection of Casks to audit" do it "audits all Casks if no tokens are given" do - allow(Cask::Cask).to receive(:to_a).and_return([cask, cask]) + allow(Cask::Cask).to receive(:all).and_return([cask, cask]) expect(Cask::Auditor).to receive(:audit).twice.and_return(result)