#!/usr/local/bin/perl -T

################################################################################
#
# $Id$
#
# Release all dependencies on a job.  Make it get into the 'Ready' state
# immediately. 
#
################################################################################

use strict;
use warnings;
use Carp;
use TaskForest::LogDir;
use TaskForest::Options;
use TaskForest::Release;
use Getopt::Long;

my $family_job_name = '';
my $log_dir_root;
my $help;
my $family_dir = '';

my $got_options = Getopt::Long::GetOptions(
    "job=s"             => \$family_job_name,
    "log_dir=s"         => \$log_dir_root,
    "help"              => \$help,
    "family_dir=s"      => \$family_dir,
    );



if ($help 
    or !$log_dir_root
    or !$family_job_name
    or !$family_dir
    ) {
    print "Usage: release --job=Ff::Jj --log_dir=log_directory --family_dir=family_directory\n\n";
    exit 1;
}


if ($family_job_name !~ /^([a-z0-9_]+)::([a-z0-9_\-]+)$/i) {
    print "Usage: release --job=Ff:Jj --log_dir=log_directory --family_dir=family_directory\n\n";
    confess("\nThe --job command line argument must be of the form: Ff::Jj where\n",
            "Ff is the family name and Jj is the job name\n\n");
}
my ($family_name, $job_name) = ($1, $2);

my $log_dir      = &TaskForest::LogDir::getLogDir($log_dir_root);

&TaskForest::Release::release($family_name, $job_name, $log_dir, $family_dir);

exit 0;
