#!/usr/bin/perl
use strict;
$|++;

my $VERSION = '0.04';

#----------------------------------------------------------------------------

=head1 NAME

cpanreps-writepages - script to create the CPAN Testers Reports website.

=head1 SYNOPSIS

  perl cpanreps-writepages -c=<file> [-d=<directory>]

=head1 DESCRIPTION

Using the cpanstats database, extracts all the data into the components of
each page. Then creates each HTML page for the site.

=cut

# -------------------------------------
# Library Modules

use FindBin;
use lib ("$FindBin::Bin/../lib", "../lib");
use CPAN::WWW::Testers;
use Getopt::ArgvFile default=>1;
use Getopt::Long;
use File::Path;

# -------------------------------------
# Variables

my (%options);

# -------------------------------------
# Program

##### INITIALISE #####

init_options();

##### MAIN #####

my $t = CPAN::WWW::Testers->new(%options);
$t->generate;

# -------------------------------------
# Subroutines

sub init_options {
    GetOptions( \%options,
        'directory|d=s',
        'config|c=s',
        'help|h',
        'version|v'
    );

    help(1) if($options{help});
    help(0) if($options{version});
}

sub help {
    my ($full,$mess) = @_;

    print "\n$mess\n"	if($mess);

    if($full) {
        print <<HERE;

Usage: $0 \\
         -c file [-d directory] [-h] [-v]

  -c file       database configuration file [required]
  -d directory  target directory for website files
  -h            this help screen
  -v            program version

HERE

    }

    print "$0 v$VERSION\n\n";
    exit(0);
}

__END__

=head1 BUGS, PATCHES & FIXES

There are no known bugs at the time of this release. However, if you spot a
bug or are experiencing difficulties, that is not explained within the POD
documentation, please send bug reports and patches to the RT Queue (see below).

Fixes are dependant upon their severity and my availablity. Should a fix not
be forthcoming, please feel free to (politely) remind me.

RT: http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-WWW-Testers

=head1 SEE ALSO

L<CPAN::WWW::Testers::Generator>
L<CPAN::Testers::WWW::Statistics>

F<http://www.cpantesters.org/>,
F<http://stats.cpantesters.org/>

=head1 AUTHOR

  Original author:    Leon Brocard <acme@astray.com>   200?-2008
  Current maintainer: Barbie       <barbie@cpan.org>   2008-present

=head1 COPYRIGHT AND LICENSE

  Copyright (C) 2002-2008 Leon Brocard <acme@astray.com>
  Copyright (C) 2008-2009 Barbie <barbie@cpan.org>

  This module is free software; you can redistribute it and/or
  modify it under the same terms as Perl itself.

=cut
