# -*-perl-*-
# vim: syntax=perl

# $Id$

# Front-end to print backup info

# $Log$
# Revision 1.1  2007/02/07 17:18:14  thomas
# UI for sushi what data
#
# Revision 1.1  2007/02/07 17:16:08  thomas
# I dunno what this is.
#

package Sushi::Command::BackupInfo;

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

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

sub main {
  my ($class) = shift;

  my ($args, $host);
  my $opts = {};

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

  if (defined $opts->{help}) {
    printhelp ();
    return 1;
  }

  Sushi::GenDB::displayHeader (
                               {print_headings => 1},
                               $::table_defs->{notable_backupinfo},
                              );

  my $rows;
  foreach $host (@ARGV) {
    my $backups = Sushi::BackupInfo->getBackups ($host);
    if (defined $backups) {
      print "$host:\n";
      $rows=0;
      foreach (@$backups) {
	Sushi::GenDB::displayRow (
                                {},
                                $::table_defs->{notable_backupinfo},
                                $_,
                               );
	$rows++;
      }
      Sushi::GenDB::displayTrailer (
				    {print_headings => 1},
				    $::table_defs->{notable_backupinfo},
				    $rows,
				   );

    }
  }
  return 0;
}

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

sub aliases {
  return ();
}

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

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

sub shortHelp {
  return "Report backup information from What configuration";
}

sub help {
  my $help = <<__Eof__

afspurge <options>

options: [--showlist] [(--volume_name|-v) <b.vol.999...>]

The afspurge command is used to remove old afs volumes from the sushi
on-line pool.  It will remove volumes that have nothing but purged
results in them.  It is typically run after the sushi purge command.

`afspurge --showlist` doesn't purge any volumes, but shows the list of
volumes that would be purged.

__Eof__
;
}

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

1;
