# 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 AddUser
    def self.main(argv)
      if argv.length < 2
	puts "usage: adduser [sitename] [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.get_site(sitename)
	site.member.add(mail)
      rescue
	puts "Error: site does not exist."
	exit 1
      end
      puts "add uesr completed."
    end
  end
end
