21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/google-ime-skk/cli.rb', line 21
def self.execute
opts = OpenStruct.new({
:port => 55100,
:host => '0.0.0.0',
:proxy => nil,
:cache_time => 3600,
})
OptionParser.new do |parser|
parser.instance_eval do
self.banner = "Usage: #{$0} [opts]"
separator ''
separator 'Options:'
on('-p', '--port 55100', 'Listen port number') do |port|
opts.port = port
end
on('-h', '--host "0.0.0.0"', 'Listen hostname') do |host|
opts.host = host
end
on('-x', '--proxy "http://proxy.example.com:8080"', 'HTTP Proxy server') do |proxy|
opts.proxy = URI.parse(proxy)
end
on('-c', '--cache-time 1h', 'Cache keep time') do |ct|
opts.cache_time = GoogleImeSkk::CLI.time_parse(ct)
end
parse!(ARGV)
end
end
ime = GoogleImeSkk.new(opts.host, opts.port, opts.proxy, opts.cache_time)
ime.mainloop
end
|