aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/cli/audit.rb
blob: 35d82800c601419a6253e6d02e2b16ae5ea8538f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Hbc
  class CLI
    class Audit < AbstractCommand
      option "--download",        :download,        false
      option "--token-conflicts", :token_conflicts, false

      def self.help
        "verifies installability of Casks"
      end

      def run
        failed_casks = casks(alternative: -> { Hbc.all })
                       .reject { |cask| audit(cask) }

        return if failed_casks.empty?
        raise CaskError, "audit failed for casks: #{failed_casks.join(" ")}"
      end

      def audit(cask)
        odebug "Auditing Cask #{cask}"
        Auditor.audit(cask, audit_download: download?, check_token_conflicts: token_conflicts?)
      end

      def self.needs_init?
        true
      end
    end
  end
end