#!/usr/bin/ruby

USAGE = "Usage: ckconvert [options] componentname ..."

$LOAD_PATH.unshift '../lib'

require 'optparse'
require 'cgikit/project/converter'
include CGIKit::Project

def show_usage
  puts USAGE
  exit
end

path = ja = nil
use_ckid = true
opt = OptionParser.new
opt.on("-o PATH", "Place the output into PATH") do |v| path = v end
opt.on("--id", "Change marking to id attribute") do |v| use_ckid = false end
opt.on("--ckid", "Change marking to ckid attribute (default)") do |v| use_ckid = true end

begin
  opt.parse!(ARGV)
rescue
  show_usage
end

show_usage if ARGV.empty?

path ||= Dir.pwd
conv = ComponentConverter.new(ARGV, use_ckid)
conv.write(path)
