Method: Excavator::DSL#command

Defined in:
lib/excavator/dsl.rb

#command(name, &block) ⇒ Object

Public: Creates a command to add to Excavator.runner.

name - A String or Symbole for the command. block - A block of code to execute when the command is called. This block

is executed within an instance of Excavator::Environment.

Examples

command :hello do
  puts "hello"
end

Returns a Command.



115
116
117
118
119
120
121
122
# File 'lib/excavator/dsl.rb', line 115

def command(name, &block)
  cmd = Excavator.runner.last_command
  cmd.name = name
  cmd.block = block
  Excavator.runner.current_namespace << cmd
  Excavator.runner.clear_last_command!
  cmd
end