src/ruby/pb/test/client.rb
# validates the the command line options, returning them as a Hash.
validates the the command line options, returning them as a Hash.
validates the the command line options returning them as a Hash .
def parse_args
  args = Args.new
  args.host_override = 'foo.test.google.fr'
  OptionParser.new do |opts|
    opts.on('--oauth_scope scope',
            'Scope for OAuth tokens') { |v| args['oauth_scope'] = v }
    opts.on('--server_host SERVER_HOST', 'server hostname') do |v|
      args['host'] = v
    end
    opts.on('--default_service_account email_address',
            'email address of the default service account') do |v|
      args['default_service_account'] = v
    end
    opts.on('--server_host_override HOST_OVERRIDE',
            'override host via a HTTP header') do |v|
      args['host_override'] = v
    end
    opts.on('--server_port SERVER_PORT', 'server port') { |v| args['port'] = v }
    test_cases = NamedTests.instance_methods(false).map(&:to_s)
    test_case_list = test_cases.join(',')
    opts.on('--test_case CODE', test_cases, {}, 'select a test_case',
            "  (#{test_case_list})") { |v| args['test_case'] = v }
    opts.on('--use_tls USE_TLS', ['false', 'true'],
            'require a secure connection?') do |v|
      args['secure'] = v == 'true'
p    end
    opts.on('--use_test_ca USE_TEST_CA', ['false', 'true'],
            'if secure, use the test certificate?') do |v|
      args['use_test_ca'] = v == 'true'
    end
  end.parse!
  _check_args(args)
end
def parse_args args = Args . new args . host_override = 'foo.test.google.fr' OptionParser . new do | opts | opts . on ( '--oauth_scope scope' , 'Scope for OAuth tokens' ) { | v | args [ 'oauth_scope' ] = v } opts . on ( '--server_host SERVER_HOST' , 'server hostname' ) do | v | args [ 'host' ] = v end opts . on ( '--default_service_account email_address' , 'email address of the default service account' ) do | v | args [ 'default_service_account' ] = v end opts . on ( '--server_host_override HOST_OVERRIDE' , 'override host via a HTTP header' ) do | v | args [ 'host_override' ] = v end opts . on ( '--server_port SERVER_PORT' , 'server port' ) { | v | args [ 'port' ] = v } test_cases = NamedTests . instance_methods ( false ) . map ( & :to_s ) test_case_list = test_cases . join ( ',' ) opts . on ( '--test_case CODE' , test_cases , { } , 'select a test_case' , "  (#{test_case_list})" ) { | v | args [ 'test_case' ] = v } opts . on ( '--use_tls USE_TLS' , [ 'false' , 'true' ] , 'require a secure connection?' ) do | v | args [ 'secure' ] = v == 'true' p end opts . on ( '--use_test_ca USE_TEST_CA' , [ 'false' , 'true' ] , 'if secure, use the test certificate?' ) do | v | args [ 'use_test_ca' ] = v == 'true' end end . parse! _check_args ( args ) end
validates the the command line options, returning them as a Hash.
validates the the command line options returning them as a Hash .
# instance_methods(false) gives only the methods defined in that class