aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/cli/internal_help.rb
blob: beac77b29377a1615827c04915776eb30e28553f (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 InternalHelp < AbstractInternalCommand
      def initialize(*)
        super
        return if args.empty?
        raise ArgumentError, "#{self.class.command_name} does not take arguments."
      end

      def run
        max_command_len = CLI.commands.map(&:length).max
        puts "Unstable Internal-use Commands:\n\n"
        CLI.command_classes.each do |klass|
          next if klass.visible
          puts "    #{klass.command_name.ljust(max_command_len)}  #{self.class.help_for(klass)}"
        end
        puts "\n"
      end

      def self.help_for(klass)
        klass.respond_to?(:help) ? klass.help : nil
      end

      def self.help
        "print help strings for unstable internal-use commands"
      end
    end
  end
end