#!/usr/bin/env ruby
# $Id: makesite,v 1.1 2004/05/10 09:48:48 eto Exp $
# Copyright (C) 2003-2004 Kouichirou Eto, 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 GPL2.

base = File.dirname(__FILE__)+"/.."
$LOAD_PATH.unshift(File.expand_path(base+"/lib"))
$LOAD_PATH.unshift(File.expand_path(base+"/compat"))

require "qwik/config"
require "qwik/site"
require "qwik/ext_member"

def main(argv)
  if argv.length < 2
    puts "usage: makesite [sitename] [your mail address]"
    exit
  end

  config = Qwik::Config.new
  farm = Qwik::Farm.new(config)
  sitename = argv.shift
  mail = argv.shift
  begin
    site = farm.make_site(sitename)
    site.member.add(mail)
  rescue
    puts "Error: the site is already exsit."
    exit 1
  end
  puts "create site completed."
end
main(ARGV)
