#!/usr/bin/env ruby

#
# $Id: checktool.rb,v 1.1 2004/01/17 12:02:25 hn Exp $
# Copyright Narushima Hironori. All rights reserved.
#

require 'getopts'

libdir = File::dirname(__FILE__)  + '/../lib'
if /cygwin$/ === RUBY_PLATFORM
	load libdir + '/cygpath.rb'
	libdir = Cygwin::cygpath(libdir)
end
$:.unshift(libdir)

unless getopts(nil, 'd:')
	abort "Usage: $wpchecktool -d[distfile] entries"
end

require 'webpub/install_checker'

default_entries = %w[
	amrita webpub/install_checker_items.rb Webpub::AmritaChecker
	rd webpub/install_checker_items.rb Webpub::RDChecker
	interpreter webpub/install_checker_items.rb Webpub::InterpreterChecker]

1.step(default_entries.length, 3) { |i|
	default_entries[i] = File.join(libdir, default_entries[i])
}

arg = $*.size < 3 ? default_entries : $*
if /cygwin$/ === RUBY_PLATFORM
	1.step(arg.length, 3) { |i|
		arg[i] = Cygwin::cygpath(arg[i])
	}
end

mgr = Webpub::InstallCheckerManager::new_as_args(arg)
if $OPT_d
	mgr.dist_result($OPT_d)
else
	mgr.expand_result($stdout)
end
