#!/usr/bin/perl -w
use strict;
use Cwd;
use FindBin;
use lib ("$FindBin::Bin/../lib", "../lib");
use CPAN::WWW::Testers::Generator   "0.21";
use Getopt::Long;

our ($opt_d, $opt_n, $opt_c, $opt_h);
GetOptions( 
    'directory|d=s' => \$opt_d, 
    'news|n'        => \$opt_n, 
    'create|c'      => \$opt_c, 
    'help|h'        => \$opt_h,
);

if ( $opt_h ) {
    print <<HERE;
Usage: cpan_www_testers_generate [-d directory] [-n] [-c] [-h]
  -d directory   use named directory
  -n             download NNTP articles to news.db only
  -c             recreate testers.db from news.db
  -h             this help screen
HERE
    exit 1;
}

my $t = CPAN::WWW::Testers::Generator->new();

my $directory = $opt_d || cwd();
$t->directory($directory);

unlink "$directory/testers.db"  if($opt_c);

if($opt_n)      { $t->download; }
elsif($opt_c)   { $t->insert;   }
else            { $t->generate; }
