#!/usr/pkg/bin/ruby32
# coding: utf-8

#
# == NAME
#
# jcolorc - Japanese color name compiler
#
# == SYNOPSIS
#
#    jcolorc [options] < default.css.in > default.css
#    jcolorc [options] default.css.in -o default.css
#
# == DESCRIPTION
#
# jcolorc is a filter to convert from Japanese color name to RGB value.
#
#
# == SYNTAX
#
# [<tt>##<em><color name></em></tt>]
#     Replace with RGB value for <em><color name></em>.
#
#     You can use kanji, hiragana, katakana and romaji for <em><color name></em>.
#
# [<tt>##alias <em><new color name></em> <em><color name></em></tt>]
#     Gives alias to <em><color name></em>.
#
#
# == EXAMPLE
#
# === Short example:
#
#   % echo color: ##sakura-iro | jcolorc
#   color: #fbdade
#
# === Long example:
#
# INPUT (default.css.in):
#
#     @charset "Shift_JIS";
#     body {
#         color: ##暗黒色;
#         background: ##sakura-iro;
#     }
#     .warning {
#         color: ##こいくれない;
#         background: ##ニジイロ;
#         border: 2px solid #ff0000;
#         padding: 4px;
#     }
#
# FILTER COMMAND:
#
#     % jcolorc -p traditional -Ks -o default.css default.css.in
#
# OUTPUT (default.css):
#
#     @charset "Shift_JIS";
#     body {
#         color: #16160e;
#         background: #fef4f4;
#     }
#     .warning {
#         color: #a22041;
#         background: #f6bfbc;
#         border: 2px solid #ff0000;
#         padding: 4px;
#     }
#
#
# === alias example:
#
# Gives logical name for shinku (真紅).
#
# INPUT (default.css.in):
#
#     ##alias my-red shinku
#     table, th, td {
#         border: 1px solid ##my-red;
#     }
#     .column {
#         border: 2px dotted ##my-red;
#     }
#
# FILTER COMMAND:
#
#     % jcolorc -p traditional -o default.css default.css.in
#
# OUTPUT (default.css):
#
#     table, th, td {
#         border: 1px solid #a22041;
#     }
#     .column {
#         border: 2px dotted #a22041;
#     }
#
#
# == USAGE
#
#     Usage: jcolorc [options] <source file>
#
#       Options:
#         -o, --output <output file>       output file (default: stdout)
#         -p, --pallet <color pallet>      color pallet (jis or traditional).
#                                          (default: jis)
#         -K<kcode>                        specifies KANJI code-set (default: UTF-8)
#         -E                               output preprocessed ERB script
#             --prefix=<directive prefix>  prefix the pre-processor directive.
#                                          (default: ##)
#
#         -v, --version                    print the version
#         -h, --help                       print this message
#

require "rubygems"
require "color/rgb/jp/compiler/command"

Color::RGB::JP::Compiler::Command.dispatch
