# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/config"
require "qwik/memory"
require "qwik/farm"

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

      config = Config.new
      memory = ServerMemory.new(config)
      farm = Farm.new(config, memory)
      sitename = argv.shift
      mail = argv.shift
      begin
	site = farm.make_site(sitename)
	site = farm.get_site(sitename)
	site.member.add(mail)
      rescue => e
	puts "Error: the site is already exsit."
	exit 1
      end
      puts "create site completed."
    end
  end
end
