Method: #parse_options
- Defined in:
- src/ruby/pb/test/server.rb
permalink #parse_options ⇒ Object
validates the command line options, returning them as a Hash.
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'src/ruby/pb/test/server.rb', line 215 def = { 'port' => nil, 'secure' => false } OptionParser.new do |opts| opts. = 'Usage: --port port' opts.on('--port PORT', 'server port') do |v| ['port'] = v end opts.on('--use_tls USE_TLS', ['false', 'true'], 'require a secure connection?') do |v| ['secure'] = v == 'true' end end.parse! if ['port'].nil? fail(OptionParser::MissingArgument, 'please specify --port') end end |