Class: Choosy::DSL::CommandBuilder

Inherits:
BaseCommandBuilder show all
Defined in:
lib/choosy/dsl/command_builder.rb

Instance Attribute Summary

Attributes inherited from BaseCommandBuilder

#entity

Instance Method Summary collapse

Methods inherited from BaseCommandBuilder

#boolean, #boolean_, #enum, #enum_, #heading, #help, #initialize, #no_color, #option, #para, #printer, #summary, #version

Methods included from BaseBuilder

#evaluate!, #method_missing

Constructor Details

This class inherits a constructor from Choosy::DSL::BaseCommandBuilder

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Choosy::DSL::BaseBuilder

Instance Method Details

#arguments(&block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/choosy/dsl/command_builder.rb', line 18

def arguments(&block)
  builder = ArgumentBuilder.new
  # Set multiple by default
  builder.entity.multiple!
  builder.evaluate!(&block)
  
  if builder.entity.metaname.nil?
    builder.metaname 'ARGS+'
  end

  entity.arguments = builder.entity
end

#executor(exec = nil, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/choosy/dsl/command_builder.rb', line 3

def executor(exec=nil, &block)
  if exec.nil? 
    if block_given?
      @entity.executor = block
    else
      raise Choosy::ConfigurationError.new("The executor was nil")
    end
  else
    if !exec.respond_to?(:execute!)
      raise Choosy::ConfigurationError.new("Execution class doesn't implement 'execute!'")
    end
    @entity.executor = exec
  end
end