Class: Gts::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/gts/command.rb

Defined Under Namespace

Classes: CommandError, UnknownCommand

Constant Summary collapse

@@known_commands =
{}
@@known_commands_descriptions =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



13
14
15
# File 'lib/gts/command.rb', line 13

def args
  @args
end

Class Method Details

.execute(command_str) ⇒ Object



20
21
22
23
24
# File 'lib/gts/command.rb', line 20

def self.execute(command_str)
  parser = Gts::CommandParser.new
  command_name, @args = *parser.parse(command_str)
  command_handler(command_name.to_sym).execute
end

.known_commands_descriptionsObject



26
27
28
# File 'lib/gts/command.rb', line 26

def self.known_commands_descriptions
  @@known_commands_descriptions
end

.register(name, handler, desc = "") ⇒ Object



15
16
17
18
# File 'lib/gts/command.rb', line 15

def self.register(name, handler, desc="")
  @@known_commands[name] = handler
  @@known_commands_descriptions[name] = desc
end