Created
August 29, 2012 08:46
-
-
Save tobynet/3508699 to your computer and use it in GitHub Desktop.
erokimos text-converter CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
program = File.basename($PROGRAM_NAME) | |
USAGE = <<EOD | |
usage: #{program} text | |
example: | |
$ #{program} "みんなでワイワイ バーベキューなう" | |
たわわに実るみんなでワイワイ 甘美なバーベキューなう | |
or | |
$ echo "みんなでワイワイ バーベキューなう" | #{program} | |
ピンク色のみんなでワイワイ 柔らかなバーベキューなう | |
EOD | |
API_URI="http://erokimos.jgate.de" | |
require 'net/http' | |
if $stdin.tty? && ARGV.empty? | |
puts USAGE | |
else | |
text = ARGV.shift || ARGF.read #|| "みんなでワイワイ バーベキューなう" | |
puts Net::HTTP.get(URI(URI.encode("#{API_URI}/convert?q=#{text}"))) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment