Sha256: caaadf9341eae9da0ae86c4f7a412b1bd41b9040003979670347a88f86ab338a
Contents?: true
Size: 1002 Bytes
Versions: 7
Compression:
Stored size: 1002 Bytes
Contents
#!/usr/bin/env ruby require 'rubygems' 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 end begin opts.parse!(args) rescue 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
7 entries across 7 versions & 1 rubygems