Sha256: da2ed5e05ffc4483180e9dd708fa44d252119d655ada05cc759f2aa3d5dc5d09

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby

require 'ostruct'
require 'optparse'
require 'flapjack/patches'

module Flapjack
  module Worker
    class CLI
      def self.parse(args)
        options = OpenStruct.new
        opts = OptionParser.new do |opts|
          # the available command line options
          opts.on('-b', '--beanstalk HOST', 'location of the beanstalkd') do |host|
            options.host = host
          end
          opts.on('-p', '--port PORT', 'beanstalkd port') do |port|
            options.port = port.to_i
          end
          opts.on('-c', '--checks-directory DIR', 'sandboxed check directory') do |dir|
            options.checks_directory = dir.to_s
          end
          opts.on_tail("-h", "--help", "Show this message") do
            puts opts
            exit
          end
        end

        # parse the options
        begin
          opts.parse!(args)
        rescue OptionParser::MissingArgument => e
          # if an --option is missing it's argument
          puts e.message.capitalize + "\n\n"
          puts opts
          exit 1
        end

        # default the port
        options.host ||= 'localhost'
        options.port ||= 11300
        options.checks_directory ||= File.join(File.dirname(__FILE__), '..', 'checks')

        options
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
flapjack-0.6.39 lib/flapjack/worker/cli.rb
flapjack-0.6.38 lib/flapjack/worker/cli.rb
flapjack-0.6.37 lib/flapjack/worker/cli.rb
flapjack-0.6.36 lib/flapjack/worker/cli.rb
flapjack-0.6.35 lib/flapjack/worker/cli.rb
flapjack-0.6.34 lib/flapjack/worker/cli.rb
flapjack-0.6.33 lib/flapjack/worker/cli.rb
flapjack-0.6.32 lib/flapjack/worker/cli.rb
flapjack-0.6.31 lib/flapjack/worker/cli.rb
flapjack-0.6.30 lib/flapjack/worker/cli.rb
flapjack-0.6.29 lib/flapjack/worker/cli.rb
flapjack-0.6.28 lib/flapjack/worker/cli.rb
flapjack-0.6.27 lib/flapjack/worker/cli.rb
flapjack-0.6.26 lib/flapjack/worker/cli.rb
flapjack-0.6.25 lib/flapjack/worker/cli.rb
flapjack-0.6.24 lib/flapjack/worker/cli.rb
flapjack-0.6.23 lib/flapjack/worker/cli.rb