cat.rb 822 Bytes
Newer Older
Markus Reiter's avatar
Markus Reiter committed
1
# typed: strict
2
3
# frozen_string_literal: true

Markus Reiter's avatar
Markus Reiter committed
4
module Cask
Mike McQuaid's avatar
Mike McQuaid committed
5
  class Cmd
Markus Reiter's avatar
Markus Reiter committed
6
7
8
    # Implementation of the `brew cask cat` command.
    #
    # @api private
9
    class Cat < AbstractCommand
Markus Reiter's avatar
Markus Reiter committed
10
11
12
      extend T::Sig

      sig { override.returns(T.nilable(T.any(Integer, Symbol))) }
13
14
15
16
      def self.min_named
        :cask
      end

Markus Reiter's avatar
Markus Reiter committed
17
      sig { returns(String) }
18
19
      def self.description
        "Dump raw source of a <cask> to the standard output."
Markus Reiter's avatar
Markus Reiter committed
20
21
      end

Markus Reiter's avatar
Markus Reiter committed
22
      sig { void }
Markus Reiter's avatar
Markus Reiter committed
23
      def run
24
        casks.each do |cask|
25
26
27
28
29
30
          if Homebrew::EnvConfig.bat?
            ENV["BAT_CONFIG_PATH"] = Homebrew::EnvConfig.bat_config_path
            safe_system "#{HOMEBREW_PREFIX}/bin/bat", cask.sourcefile_path
          else
            puts File.open(cask.sourcefile_path, &:read)
          end
Markus Reiter's avatar
Markus Reiter committed
31
        end
32
33
      end
    end
AnastasiaSulyagina's avatar
init  
AnastasiaSulyagina committed
34
35
  end
end