diff options
author | John Keiser <jkeiser@opscode.com> | 2014-06-10 20:52:56 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-06-10 20:54:08 -0700 |
commit | d60221a7e5539874516bbfe75a5701d7e3b90971 (patch) | |
tree | b7f12bbea878b127403fa28734394fcbaa0985b7 /bin | |
parent | 25fe70279ea8eb89b360131e95ce65f6a8696992 (diff) | |
download | chef-zero-d60221a7e5539874516bbfe75a5701d7e3b90971.tar.gz |
Allow port ranges to be specified on the command line
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/chef-zero | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/bin/chef-zero b/bin/chef-zero index 6d6884f..c2b3120 100755 --- a/bin/chef-zero +++ b/bin/chef-zero @@ -10,6 +10,19 @@ require 'chef_zero/version' require 'chef_zero/server' require 'optparse' +def parse_port(port) + array = [] + port.split(',').each do |part| + a,b = part.split('-',2) + if b + array = array.concat(a.to_i.upto(b.to_i).to_a) + else + array = array.concat([a.to_i]) + end + end + array +end + options = {} OptionParser.new do |opts| @@ -19,8 +32,9 @@ OptionParser.new do |opts| options[:host] = value end - opts.on("-p", "--port PORT", Integer, "Port to listen on") do |value| - options[:port] = value + opts.on("-p", "--port PORT", "Port to listen on (e.g. 8889, or 8500-8600 or 8885,8888)") do |value| + options[:port] ||= [] + options[:port] += parse_port(value) end opts.on("--[no-]generate-keys", "Whether to generate actual keys or fake it (faster). Default: false.") do |value| |