Sha256: 4301a6003e770007361cbd6719ce4aa8019a5c5efdc968deceb438a0aad66505

Contents?: true

Size: 1.09 KB

Versions: 21

Compression:

Stored size: 1.09 KB

Contents

#!/usr/bin/env ruby

require 'ostruct'
require 'optparse'

class WorkerManagerOptions
  def self.parse(args)
    options = OpenStruct.new
    opts = OptionParser.new do |opts|
      opts.banner = "Usage: flapjack-worker-manager <command> [options]"
      opts.separator " "
      opts.separator "  where <command> is one of:"
      opts.separator "     start            start a worker"
      opts.separator "     stop             stop all workers"
      opts.separator "     restart          restart workers"
      opts.separator " "
      opts.separator "  and [options] are:"

      opts.on('-w', '--workers N', 'number of workers to spin up') do |workers|
        options.workers = workers.to_i
      end
      opts.on('-c', '--checks-directory DIR', 'sandboxed check directory') do |dir|
        options.check_directory = dir
      end
    end

    begin
      opts.parse!(args)
    rescue => e
      puts e.message.capitalize + "\n\n"
      puts opts
      exit 1
    end

    options.workers ||= 5

    unless %w(start stop restart).include?(args[0])
      puts opts
      exit 1
    end

    options
  end
end


Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
flapjack-0.6.43 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.42 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.41 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.40 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.39 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.38 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.37 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.36 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.35 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.34 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.33 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.32 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.31 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.30 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.29 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.28 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.27 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.26 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.25 lib/flapjack/cli/worker_manager.rb
flapjack-0.6.24 lib/flapjack/cli/worker_manager.rb