# -*-perl-*-

# $Id: Alias.plm,v 1.4 2003/06/09 14:45:11 thomas Exp $

# Front-end to add, remove, or list limits in the db.

# $Log: Alias.plm,v $
# Revision 1.4  2003/06/09 14:45:11  thomas
# schema version of database
#
# Revision 1.3  2002/08/20 21:59:56  thomas
# installed 0.3.0
#
# Revision 1.2  2002/07/08 15:56:34  thomas
# 0.2.3 release
#
# Revision 1.1.1.1  2002/05/21 14:13:35  thomas
# sushi - backup to disk
#

package Sushi::Command::Alias;

use strict;
use Getopt::Long;
use Data::Dumper;

my %subs = (
	    add      => \&Sushi::GenDB::add,
	    list     => \&Sushi::GenDB::display,
	    del      => \&Sushi::GenDB::del,
	    help     => \&printhelp,
	    '--help' => \&printhelp
	   );

###############################################################################

sub main {
  my ($class) = shift;
  my $cmd = shift @ARGV;

  my $args = {};

  Getopt::Long::Configure ("bundling");
  my $res;
  if (!($res = GetOptions (
			   'resource_name|n=s',  \$args->{resource_name},
			   'resource_alias|a=s', \$args->{resource_alias}
			  ))) {
    $main::log->error (&help);
    return 0;
  }

  defined ($ARGV[0]) and $args->{resource_alias} = shift @ARGV;
  defined ($ARGV[0]) and $args->{resource_name} = shift @ARGV;

  if (defined $subs{$cmd}) {
    return $subs{$cmd}(
		       $args,
		       {
			print_headings => 1,
			print_results => 1
		       },
		       $::table_defs->{res_alias}
		      );
  }
  $main::log->error("Bad limit sub-command specified\n");
  return;

}

###############################################################################

sub shortHelp {
  return "Add, delete, or list constraint variable names";
}

sub printhelp {
  print help();
  return 1;
}

sub help {
  my $help = <<__Eof__

alias\tadd <options>
\tdel <options>
\tlist <options>
options:\t[(--resource_alias|-a) <alias>][(--resource_name|-n) <resource>]
\t[<alias> [<resource>]]
__Eof__
;
}

###############################################################################

1;
