/usr/bin/migemo-client is in migemo 0.40-10.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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 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 | #!/usr/bin/ruby
#
# migemo-client - a client to communicate with migemo-server.
#
# Copyright (C) 2001 Hidai Kenichi <hidai@symbio.jst.go.jp>
# All rights reserved.
# This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms of
# the GNU General Public License version 2.
#
$KCODE = "e"
require 'net/http'
require 'getoptlong'
require 'nkf'
def usage
print "\
Usage: migemoc-client [OPTION] PATTERN...
-h, --help Display this help and exit
-H, --host=HOST Set hostname of Migemo server to HOST.
-p, --port=PORT Set port number of Migemo server to PORT.
-d, --dict=DICT Use DICT as a static dictionary.
-u, --user-dict=DICT Use DICT as a user dictionary.
-r, --regex-dict=DICT Use DICT as a regex dictionary.
-i, --insert=STRING Insert STRING to each character.
-t, --type=TYPE Set regex type to TYPE ([egrep], emacs, perl, ruby)
"
end
def main
options = Hash.new
parser = GetoptLong.new
parser.set_options(['--help', '-h', GetoptLong::NO_ARGUMENT],
['--host', '-H', GetoptLong::REQUIRED_ARGUMENT],
['--port', '-p', GetoptLong::REQUIRED_ARGUMENT],
['--dict', '-d', GetoptLong::REQUIRED_ARGUMENT],
['--type', '-t', GetoptLong::REQUIRED_ARGUMENT],
['--user-dict', '-u', GetoptLong::REQUIRED_ARGUMENT],
['--regex-dict', '-r', GetoptLong::REQUIRED_ARGUMENT],
['--insert', '-i', GetoptLong::REQUIRED_ARGUMENT])
parser.each_option do |name, arg|
options[name.sub(/^--/, "")] = arg
end
if ARGV.empty? || options['help']
usage
exit 1
end
host = 'localhost'
port = 31413
dict = 'migemo-dict'
type = 'ruby'
host = options['host'] if options['host']
port = options['port'] if options['port']
dict = options['dict'] if options['dict']
type = options['type'] if options['type']
path = '/?dict=' + dict
path << '&type=' + type
path << '&insertion=' + options['insert'] if options['insert']
path << '&user-dict=' + options['user-dict'] if options['user-dict']
path << '®ex-dict=' + options['regex-dict'] if options['regex-dict']
utf8 = (ENV['LANG'] || "").include?("UTF-8")
ARGV.each do |pattern|
Net::HTTP.start(host, port) {|http|
response, body = http.get(sprintf("%s&pattern=%s", path, pattern))
puts utf8 ? NKF.nkf("-Ew", body) : body
}
end
end
main
|