Class: SnowmanIO::Options
- Inherits:
-
Object
- Object
- SnowmanIO::Options
- Defined in:
- lib/snowman-io/options.rb
Overview
Parse command line.
Instance Method Summary collapse
Instance Method Details
#parse!(args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/snowman-io/options.rb', line 6 def parse!(args) = opt_parser = OptionParser.new do |opts| opts. = "Usage: snowman [options]" opts.separator "" opts.separator "Options:" opts.on("-p", "--port PORT", "use PORT (default: #{[:port]})") do |port| [:port] = port.to_i end opts.on "-v", "--verbose", "print more verbose output" do |arg| [:verbose] = arg end opts.on '-t', '--timeout NUM', "shutdown timeout (default #{[:timeout]} seconds)" do |arg| [:timeout] = Integer(arg) end opts.on("-h", "--help", "show this message") do puts opts exit end end opt_parser.parse!(args) end |