Class: SidekiqClientCLI::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_client_cli/parser.rb

Instance Method Summary collapse

Instance Method Details

#parseObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sidekiq_client_cli/parser.rb', line 5

def parse
  CLI.new do
    option :config_path, :short => :c, :default => DEFAULT_CONFIG_PATH, :description => "Sidekiq client config file path"
    option :queue, :short => :q, :description => "Queue to place job on"
    option :retry, :short => :r, :cast => lambda { |r| SidekiqClientCLI.cast_retry_option(r) }, :description => "Retry option for job"
    argument :command, :description => "'push' to push a job to the queue"
    arguments :command_args, :required => false, :description => "command arguments"
  end.parse! do |settings|
    fail "Invalid command '#{settings.command}'. Available commands: #{COMMANDS.join(',').chomp(',')}" unless COMMANDS.include? settings.command

    if settings.command == "push" && settings.command_args.empty?
      fail "No Worker Classes to push"
    end
  end
end