#!/usr/bin/perl

if ( $#ARGV != 1 ) {
	exit print "Usage: ctmv from-element to-element\n" ;
}

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

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

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

$from = $ARGV[0] ;
$to = $ARGV[1] ;

if ( -e $from ) {
    if ( -e $to ) {
	print STDERR "'$to' already exists.\n" ;
    } else {
	if ( ! &CTCMMv( $from, $to, $projname, $spec ) ) {
	}
    }
} else {
    print STDERR "No such element '$from'.\n" ;
}
