class RainforestCli::Commands

Constants

Command
SUPPORTED_COMMANDS

Attributes

commands[R]

Public Class Methods

new() { |self| ... } click to toggle source
# File lib/rainforest_cli/commands.rb, line 11
def initialize
  @commands = []
  yield(self) if block_given?
end

Public Instance Methods

add(command, description, &blk) click to toggle source
# File lib/rainforest_cli/commands.rb, line 16
def add(command, description, &blk)
  @commands << Command.new(command, description, blk)
end
call(command_name) click to toggle source
# File lib/rainforest_cli/commands.rb, line 20
def call(command_name)
  command = @commands.find { |c| c.name == command_name }

  if command.nil?
    logger.fatal "Unknown command: #{command_name}"
    exit 2
  end

  command.block.call
end
print_documentation() click to toggle source

Private Instance Methods

logger() click to toggle source
# File lib/rainforest_cli/commands.rb, line 41
def logger
  RainforestCli.logger
end