Class: Hbc::CLI::InternalHelp

Inherits:
AbstractInternalCommand show all
Defined in:
Library/Homebrew/cask/lib/hbc/cli/internal_help.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractInternalCommand

command_name, visible

Methods inherited from AbstractCommand

abstract?, command_name, needs_init?, run, visible

Methods included from Options

included, #process_arguments

Constructor Details

#initializeInternalHelp

Returns a new instance of InternalHelp

Raises:

  • (ArgumentError)


4
5
6
7
8
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_help.rb', line 4

def initialize(*)
  super
  return if args.empty?
  raise ArgumentError, "#{self.class.command_name} does not take arguments."
end

Class Method Details

.helpObject



24
25
26
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_help.rb', line 24

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

.help_for(klass) ⇒ Object



20
21
22
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_help.rb', line 20

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

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_help.rb', line 10

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