src/ruby/pb/test/server.rb
# validates the command line options, returning them as a Hash.
validates the command line options, returning them as a Hash.
validates the command line options returning them as a Hash .
def parse_options
  options = {
    'port' => nil,
    'secure' => false
  }
  OptionParser.new do |opts|
    opts.banner = 'Usage: --port port'
    opts.on('--port PORT', 'server port') do |v|
      options['port'] = v
    end
    opts.on('--use_tls USE_TLS', ['false', 'true'],
            'require a secure connection?') do |v|
      options['secure'] = v == 'true'
    end
  end.parse!
  if options['port'].nil?
    fail(OptionParser::MissingArgument, 'please specify --port')
  end
  options
end
def parse_options options = { 'port' => nil , 'secure' => false } OptionParser . new do | opts | opts . banner = 'Usage: --port port' opts . on ( '--port PORT' , 'server port' ) do | v | options [ 'port' ] = v end opts . on ( '--use_tls USE_TLS' , [ 'false' , 'true' ] , 'require a secure connection?' ) do | v | options [ 'secure' ] = v == 'true' end end . parse! if options [ 'port' ] . nil? fail ( OptionParser :: MissingArgument , 'please specify --port' ) end options end
validates the command line options, returning them as a Hash.
validates the command line options returning them as a Hash .