Sha256: 9d87d140e76a62165539f9017c31d26c8163cb619a33f11790beef54903c2692

Contents?: true

Size: 1.23 KB

Versions: 21

Compression:

Stored size: 1.23 KB

Contents

module Toiler
  module Utils
    # Parses command-line arguments
    module ArgumentParser
      module_function

      def parse(argv)
        opts = { queues: [] }

        parser = OptionParser.new do |o|
          o.on '-d', '--daemon', 'Daemonize process' do |arg|
            opts[:daemon] = arg
          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.banner = 'toiler [options]'
        parser.on_tail '-h', '--help', 'Show help' do
          puts parser
          exit 1
        end
        parser.parse!(argv)
        opts
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
toiler-0.4.1 lib/toiler/utils/argument_parser.rb
toiler-0.4.0 lib/toiler/utils/argument_parser.rb
toiler-0.4.0.beta1 lib/toiler/utils/argument_parser.rb
toiler-0.3.5 lib/toiler/utils/argument_parser.rb
toiler-0.3.4 lib/toiler/utils/argument_parser.rb
toiler-0.3.3 lib/toiler/utils/argument_parser.rb
toiler-0.3.2 lib/toiler/utils/argument_parser.rb
toiler-0.3.1.beta4 lib/toiler/utils/argument_parser.rb
toiler-0.3.1.beta3 lib/toiler/utils/argument_parser.rb
toiler-0.3.1.beta2 lib/toiler/utils/argument_parser.rb
toiler-0.3.0 lib/toiler/utils/argument_parser.rb
toiler-0.2.9 lib/toiler/utils/argument_parser.rb
toiler-0.2.8 lib/toiler/utils/argument_parser.rb
toiler-0.2.7 lib/toiler/utils/argument_parser.rb
toiler-0.2.6 lib/toiler/utils/argument_parser.rb
toiler-0.2.5 lib/toiler/utils/argument_parser.rb
toiler-0.2.4 lib/toiler/utils/argument_parser.rb
toiler-0.2.3 lib/toiler/utils/argument_parser.rb
toiler-0.2.2 lib/toiler/utils/argument_parser.rb
toiler-0.2.1 lib/toiler/utils/argument_parser.rb