34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/groonga/client/command-line/parser.rb', line 34
def parse(arguments)
parser = OptionParser.new
parser.version = VERSION
parser.separator("")
parser.separator("Connection:")
parser.on("--url=URL",
"URL to connect to Groonga server.",
"If this option is specified,",
"--protocol, --host and --port are ignored.") do |url|
@url = url
end
available_protocols = [:http, :gqtp]
parser.on("--protocol=PROTOCOL", [:http, :gqtp],
"Protocol to connect to Groonga server.",
"[#{available_protocols.join(", ")}]",
"(#{@protocol})") do |protocol|
@protocol = protocol
end
parser.on("--host=HOST",
"Groonga server to be connected.",
"(#{@host})") do |host|
@host = host
end
parser.on("--port=PORT", Integer,
"Port number of Groonga server to be connected.",
"(auto)") do |port|
@port = port
end
parser.on("--read-timeout=TIMEOUT", Integer,
"Timeout on reading response from Groonga server.",
"You can disable timeout by specifying -1.",
"(#{@read_timeout})") do |timeout|
@read_timeout = timeout
end
yield(parser)
rest = parser.parse(arguments)
@port ||= default_port(@protocol)
rest
end
|