Class: Balboa::CLI::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/balboa/cli/application.rb

Constant Summary collapse

CommandNotFound =
Class.new(RuntimeError)

Instance Method Summary collapse

Constructor Details

#initialize(command_id) ⇒ Application

Returns a new instance of Application.



8
9
10
11
# File 'lib/balboa/cli/application.rb', line 8

def initialize(command_id)
  @command_id = command_id.to_s
  @commands = Hash.new { fail CommandNotFound }
end

Instance Method Details

#add_command(key, command) ⇒ Object



13
14
15
# File 'lib/balboa/cli/application.rb', line 13

def add_command(key, command)
  @commands[key.to_s] = command
end

#executeObject



17
18
19
# File 'lib/balboa/cli/application.rb', line 17

def execute
  @commands[@command_id].execute
end