Method: MicroQ::CLI#parse

Defined in:
lib/micro_q/cli.rb

#parseObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/micro_q/cli.rb', line 13

def parse
  opts = Slop.parse do
    banner 'Usage: microq [options]'

    on 'h', 'This menu'
    on 'help', 'This menu'
    on 't=', 'The queue type to process [redis, sqs]'
    on 'type=', 'The queue type to process [redis, sqs]'
    on 'r=', 'The path to the rails application'
    on 'require=', 'The path to the rails application'
    on 'w=', 'The number of worker threads'
    on 'workers=', 'The number of worker threads'
  end

  (puts usage; exit) if opts[:help] || opts[:h]

  @workers = opts[:workers] || opts[:w]
  @require = opts[:require] || opts[:r] || 'config/environment.rb'
  @mode = (opts[:type] || opts[:t] || 'sqs'.tap { puts 'Defaulting to sqs type' }).downcase
end