Method: CP::Command#action

Defined in:
lib/cp/command.rb

#action(&block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cp/command.rb', line 20

def action( &block )
  if !block_given?
    @action
  else
    @action = lambda { |args|
      begin
        opts = gather_options
      rescue CP::MissingOptionError => e
        CP::App.instance.fatal( "'#{e}' is required" )
      end

      block.call( args, opts )
      CP::HighLine.instance.say_buffer
    }
  end
end