#!/usr/local/bin/perl

if ( $#ARGV < 0 ) {
    exit print "Usage ctunco element-name [...]\n" ;
}

$tool = $ENV{"DTOOL"} ;
if ( $tool eq "" ) {
    die "not configured for using CTtools" ;
}

require "$tool/include/ctutils.pl" ;
require "$tool/include/ctvspec.pl" ;
require "$tool/include/ctquery.pl" ;
require "$tool/include/ctproj.pl" ;
require "$tool/include/ctcm.pl" ;

$projname = &CTProj ;
$projname =~ tr/A-Z/a-z/ ;
$flav = &CTQueryProj( $projname ) ;
$spec = &CTResolveSpec( $projname, $flav ) ;

foreach $item ( @ARGV ) {
    if ( -e $item ) {
	if ( ! &CTCMUncheckout( $item, $projname, $spec ) ) {
	    print STDERR "Could not uncheckout '$item'\n" ;
	}
    } else {
	print STDERR "No such file '$item'.\n" ;
    }
}
