#!/usr/bin/env ruby
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH << "../lib" unless $LOAD_PATH.include?("../lib")
require "qwik/catalog-validator"

if ARGV.length < 2
  puts "usage: ruby catalog-validator.rb <catalog> <source...>"
  exit
end

catalog_file = ARGV.shift
catalog = load_catalog(catalog_file)
set_catalog(catalog)

ok = true
ARGV.each {|source_file|
  validator = CatalogValidator.new(source_file, catalog)
  validator.validate
  validator.error_messages.each {|message|
    puts message
  }
  ok = (ok and validator.ok?)
}
if ok then exit else exit(1) end
