Sha256: fb436cf22886f0295ff0905856b2e881bf89a1f18ea191a3c0b96da0af204f22
Contents?: true
Size: 1.01 KB
Versions: 7
Compression:
Stored size: 1.01 KB
Contents
require 'optparse' module SnowmanIO # Parse command line. class Options def parse!(args) options = default_options opt_parser = OptionParser.new do |opts| opts.banner = "Usage: snowman [options]" opts.separator "" opts.separator "Options:" opts.on("-p", "--port PORT", "use PORT (default: #{default_options[:port]})") do |port| options[:port] = port.to_i end opts.on "-v", "--verbose", "print more verbose output" do |arg| options[:verbose] = arg end opts.on '-t', '--timeout NUM', "shutdown timeout (default #{default_options[:timeout]} seconds)" do |arg| options[:timeout] = Integer(arg) end opts.on("-h", "--help", "show this message") do puts opts exit end end opt_parser.parse!(args) options end private def default_options { :port => 4567, :timeout => 8, :host => "0.0.0.0" } end end end
Version data entries
7 entries across 7 versions & 1 rubygems