Class: Rack::App::CLI::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/app/cli/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.__option_definitions__Object



8
9
10
# File 'lib/rack/app/cli/command.rb', line 8

def __option_definitions__
  @options_parser_options ||= []
end

.action(&block) ⇒ Object



25
26
27
# File 'lib/rack/app/cli/command.rb', line 25

def action(&block)
  define_method(:action, &block)
end

.description(message = nil) ⇒ Object Also known as: desc



12
13
14
15
# File 'lib/rack/app/cli/command.rb', line 12

def description(message = nil)
  @description = message unless message.nil?
  @description || ''
end

.option(*args, &block) ⇒ Object Also known as: on



19
20
21
# File 'lib/rack/app/cli/command.rb', line 19

def option(*args, &block)
  __option_definitions__ << {:args => args, :block => block}
end

Instance Method Details

#action(*argv) ⇒ Object

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/rack/app/cli/command.rb', line 31

def action(*argv)
  raise NotImplementedError
end

#start(argv) ⇒ Object



35
36
37
38
39
# File 'lib/rack/app/cli/command.rb', line 35

def start(argv)
  action(*argv)
rescue ArgumentError => ex
  $stderr.puts(ex.message)
end