#!/usr/bin/perl

=head1 NAME

listsets - list sets in an OAI-PMH archive

=head1 SYNOPSIS

    oai-listsets --baseURL=http://preprint.chemweb.com/CPS/OAI

=head1 DESCRIPTION

A command line utility to listing the sets that belong to an OAI-PMH 
archive.

=head1 AUTHORS

=over 4 

=item * Ed Summers <ehs@pobox.com>

=back

=cut

use strict;
use Getopt::Long;
use Net::OAI::Harvester;
use Pod::Usage;

my ( $url ); 

GetOptions(
    'baseURL:s'	=> \$url
);

if ( !$url ) { 
    pod2usage( { -verbose => 0 } );
}

my $harvester = Net::OAI::Harvester->new( baseURL => $url );
my $list = $harvester->listSets();

if ( $list->errorCode() ) { 
    print STDERR $list->errorString(); 
    exit(1);
}

foreach my $spec ( $list->setSpecs() ) { 
    my $name = $list->setName( $spec );
    print "$spec ==> $name\n";
}
