# -*-perl-*-

# $Id$

# Front-end to remove empty afs volumes from the on-line pool.

# $Log$
# Revision 1.7  2010/04/27 15:48:09  koczan
# proper message
#
# Revision 1.6  2010/03/28 18:44:51  koczan
# Make the help messages correct
#
# Revision 1.5  2010/03/22 23:33:29  koczan
# I'm a goddamn moron
#
# Revision 1.4  2010/03/22 22:53:18  koczan
# fixes to afsretire --donothing
#
# Revision 1.3  2010/02/16 19:39:05  koczan
# more descriptive messages
#
# Revision 1.2  2005/03/30 22:06:38  thomas
# Doc updates
#
# Revision 1.1  2004/03/02 20:43:18  thomas
# retire empty afs volumes
#

package Sushi::Command::AfsRetire;

use strict;
use Getopt::Long;

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

sub main {
  my ($class) = shift;

  my $args;
  my $help = 0;

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

  $args->{help} and return printhelp ();
  $args->{listall} and return Sushi::AfsRetire->listall ($args);
  my $num =  Sushi::AfsRetire->retire ($args);

  print $args->{donothing} ?
    "Would delete $num volumes\n" :
    "Deleted $num volumes\n";

  return $num;
}


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

sub aliases {
  return ();
}


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

sub shortHelp {
  return "Delete empty sushi AFS volumes";
}


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

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


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

sub help {
  my $help = <<__Eof__

afsretire [--listall] [--bycount] [--donothing] [--help]

List the number of non-purged atoms in each sushi afs volume, or
purge empty volumes

	--listall lists the number of atoms in each volume.
	--bycount (with --listall) causes the afs volumes to be listed
	  by the number of ascending atoms, instead of schedule group.
	--donothing shows what commands that would be run
	  (same as '-n' but just for this subcommand).
	--help prints this message

Use 'sushi -n afsretire ...' to show the commands that would be executed,
without actually executing them.

__Eof__
  ;
}

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

1;
