Class: NatsWorker::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/nats_worker/cli.rb

Overview

Parses ARGV for ‘bin/nats_worker` and the rake task, loads the Rails environment when present, resolves which worker classes to run and hands them off to NatsWorker::Runner.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CLI

Returns a new instance of CLI.



12
13
14
15
# File 'lib/nats_worker/cli.rb', line 12

def initialize(argv)
  @argv    = argv.dup
  @options = { workers: nil, require: nil }
end

Class Method Details

.start(argv = ARGV) ⇒ Object



8
9
10
# File 'lib/nats_worker/cli.rb', line 8

def self.start(argv = ARGV)
  new(argv).run
end

Instance Method Details

#runObject



17
18
19
20
21
22
# File 'lib/nats_worker/cli.rb', line 17

def run
  parse!
  boot_app
  runner_classes = resolve_workers
  Runner.new(runner_classes).run
end