internal_help.rb 801 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 _help` command.
    #
    # @api private
9
    class InternalHelp < AbstractInternalCommand
Markus Reiter's avatar
Markus Reiter committed
10
11
12
      extend T::Sig

      sig { override.returns(T.nilable(Integer)) }
13
14
15
      def self.max_named
        0
      end
Markus Reiter's avatar
Markus Reiter committed
16

Markus Reiter's avatar
Markus Reiter committed
17
      sig { returns(String) }
18
19
      def self.description
        "Print help for unstable internal-use commands."
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
Mike McQuaid's avatar
Mike McQuaid committed
24
        max_command_len = Cmd.commands.map(&:length).max
25
        puts "Unstable Internal-use Commands:\n\n"
Mike McQuaid's avatar
Mike McQuaid committed
26
        Cmd.command_classes.each do |klass|
27
          next if klass.visible?
Markus Reiter's avatar
Markus Reiter committed
28

29
          puts "    #{klass.command_name.ljust(max_command_len)}  #{klass.help}"
30
31
32
33
        end
        puts "\n"
      end
    end
AnastasiaSulyagina's avatar
init  
AnastasiaSulyagina committed
34
35
  end
end