Enable typing in Cask::Cmd

This commit is contained in:
Douglas Eichelberger 2023-02-27 14:33:13 -08:00
parent 6611a03cc6
commit 0c533f27ba
7 changed files with 17 additions and 9 deletions

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "utils/github/actions" require "utils/github/actions"
@ -13,6 +13,7 @@ module Cask
def self.parser def self.parser
super do super do
T.bind(self, Homebrew::CLI::Parser)
switch "--[no-]download", switch "--[no-]download",
description: "Audit the downloaded file" description: "Audit the downloaded file"
switch "--[no-]appcast", switch "--[no-]appcast",
@ -44,7 +45,7 @@ module Cask
end end
casks = casks.map { |c| CaskLoader.load(c, config: Config.from_args(args)) } casks = casks.map { |c| CaskLoader.load(c, config: Config.from_args(args)) }
any_named_args = casks.any? any_named_args = casks.any?
casks = Cask.to_a if casks.empty? casks = Cask.all if casks.empty?
results = self.class.audit_casks( results = self.class.audit_casks(
*casks, *casks,

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
module Cask module Cask
@ -11,6 +11,7 @@ module Cask
def self.parser def self.parser
super do super do
T.bind(self, Homebrew::CLI::Parser)
switch "--force", switch "--force",
description: "Force redownloading even if files already exist in local cache." description: "Force redownloading even if files already exist in local cache."
end end

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "cask_dependent" require "cask_dependent"
@ -27,6 +27,7 @@ module Cask
def self.parser(&block) def self.parser(&block)
super do super do
T.bind(self, Homebrew::CLI::Parser)
switch "--force", switch "--force",
description: "Force overwriting existing files." description: "Force overwriting existing files."

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
module Cask module Cask
@ -11,6 +11,7 @@ module Cask
def self.parser def self.parser
super do super do
T.bind(self, Homebrew::CLI::Parser)
switch "--force", switch "--force",
description: "Uninstall even if the <cask> is not installed, overwrite " \ description: "Uninstall even if the <cask> is not installed, overwrite " \
"existing files and ignore errors when removing files." "existing files and ignore errors when removing files."

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "env_config" require "env_config"
@ -30,6 +30,7 @@ module Cask
sig { returns(Homebrew::CLI::Parser) } sig { returns(Homebrew::CLI::Parser) }
def self.parser def self.parser
super do super do
T.bind(self, Homebrew::CLI::Parser)
switch "--force", switch "--force",
description: "Force overwriting existing files." description: "Force overwriting existing files."
switch "--dry-run", switch "--dry-run",
@ -176,7 +177,9 @@ module Cask
return true if caught_exceptions.empty? return true if caught_exceptions.empty?
raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1 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 end
def self.upgrade_cask( def self.upgrade_cask(

View File

@ -1,4 +1,4 @@
# typed: false # typed: true
# frozen_string_literal: true # frozen_string_literal: true
module Cask module Cask
@ -11,6 +11,7 @@ module Cask
def self.parser def self.parser
super do super do
T.bind(self, Homebrew::CLI::Parser)
switch "--force", switch "--force",
description: "Ignore errors when removing files." description: "Ignore errors when removing files."
end end

View File

@ -10,7 +10,7 @@ describe Cask::Cmd::Audit, :cask do
describe "selection of Casks to audit" do describe "selection of Casks to audit" do
it "audits all Casks if no tokens are given" 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) expect(Cask::Auditor).to receive(:audit).twice.and_return(result)