Module: Toiler::Utils::ArgumentParser
- Defined in:
- lib/toiler/utils/argument_parser.rb
Overview
Parses command-line arguments
Class Method Summary collapse
Class Method Details
.parse(argv) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/toiler/utils/argument_parser.rb', line 9 def parse(argv) opts = { queues: [] } parser = OptionParser.new do |o| o.on '-d', '--daemon', 'Daemonize process' do |arg| opts[:daemon] = arg end o.on '-q', '--queue QUEUE1,QUEUE2,...', 'Queues to process' do |arg| opts[:active_queues] = arg.split(',') end o.on '-r', '--require [PATH|DIR]', 'Location of the worker' do |arg| opts[:require] = arg end o.on '-C', '--config PATH', 'Path to YAML config file' do |arg| opts[:config_file] = arg end o.on '-R', '--rails', 'Load Rails' do |arg| opts[:rails] = arg end o.on '-L', '--logfile PATH', 'Path to writable logfile' do |arg| opts[:logfile] = arg end o.on '-P', '--pidfile PATH', 'Path to pidfile' do |arg| opts[:pidfile] = arg end o.on '-v', '--verbose', 'Print more verbose output' do |arg| opts[:verbose] = arg end end parser. = 'toiler [options]' parser.on_tail '-h', '--help', 'Show help' do puts parser exit 1 end parser.parse!(argv) opts end |