Class: Karafka::Cli::Help

Inherits:
Base
  • Object
show all
Defined in:
lib/karafka/cli/help.rb

Overview

Prints info with list of commands available

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

aliases, commands, desc, #initialize, load, name, names, option, parse_options

Methods included from Helpers::Colorize

#green, #grey, #red, #yellow

Constructor Details

This class inherits a constructor from Karafka::Cli::Base

Instance Method Details

#callObject

Print available commands



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/karafka/cli/help.rb', line 11

def call
  # Find the longest command for alignment purposes
  max_command_length = self.class.commands.map(&:name).map(&:size).max

  puts 'Karafka commands:'

  # Print each command formatted with its description
  self.class.commands.each do |command|
    puts "  #{command.name.ljust(max_command_length)}    # #{command.desc}"
  end
end