use strict;

my $VERSION = '1.13';


=head1 NAME

cpanstats-writepages - script to create the CPAN Testers Statistics website.


  perl cpanstats-writepages


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


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

use lib qw(./lib ../lib);

use Getopt::ArgvFile default=>1;
use Getopt::Long;

use CPAN::Testers::WWW::Statistics;

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

my (%options);

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


my $stats = CPAN::Testers::WWW::Statistics->new(
        config    => $options{config},
        directory => $options{directory},
        templates => $options{templates},
        address   => $options{address},
        logfile   => $options{logfile},
        logclean  => $options{logclean}

if($options{all})           { $stats->make_pages();         }
else                        {
    if($options{basics})    { $stats->make_basics();        }
    if($options{update})    { $stats->update();             }
    if($options{matrix})    { $stats->make_matrix();        }
    if($options{stats})     { $stats->make_stats();         }
    if($options{leader})    { $stats->make_leaders();       }
    if($options{noreports}) { $stats->make_noreports();     }
    if($options{perform})   { $stats->make_performance();   }
    if($options{cpan})      { $stats->make_cpan();          }

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


=over 4

=item init_options

Prepare command line options.

=item help

Display the help screen.



sub init_options {
    GetOptions( \%options,

    ) or help(1);

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

    $options{all} = 1
        unless($options{basics} || $options{leader} || $options{noreports} || $options{stats}
            || $options{update} || $options{matrix} || $options{perform}   || $options{cpan});

sub help {
    my $full = shift;

    if($full) {
        print "\n";
        print "Usage:$0 --config=<file> \\\n";
        print "         [--templates=<dir>]   \\\n";
        print "         [--directory=<dir>]   \\\n";
        print "         [--address|a=<file>]  \\\n";
        print "         [--logfile=<file> [--logclean=<1|0>]] \\\n";
        print "         [--all] [--basics] [--update] [--matrix] [--stats] \\\n";
        print "         [--noreport] [--perform] [--cpan] \\\n";
        print "         [--help|h] [--version|v] \n\n";

#              12345678901234567890123456789012345678901234567890123456789012345678901234567890
        print "This program builds the CPAN Testers Statistics website.\n";

        print "\nFunctional Options:\n";
        print "  [--config=<file>]          # path to config file [required]\n";
        print "  [--templates=<dir>]        # path to templates\n";
        print "  [--directory=<dir>]        # path to website directory\n";
        print "  [--address=<file>]         # path to address file\n";
        print "  [--logfile=<file>]         # path to logfile\n";
        print "  [--logclean]		        # overwrite log if specified\n";

        print "\nRun Mode Options:\n";
        print "  [--all]                    # all modes [default if no modes given]\n";
        print "  [--basics]                 # create basic stats pages\n";
        print "  [--update]                 # update data store\n";
        print "  [--matrix]                 # create matrix style pages\n";
        print "  [--stats]                  # create stats style pages\n";
        print "  [--leader]                 # create leaderboard pages\n";
        print "  [--noreports]              # create no report pages\n";
        print "  [--perform]                # create performance pages/files\n";
        print "  [--cpan]                   # create cpan pages/files\n";

        print "\nOther Options:\n";
        print "  [--version]                # program version\n";
        print "  [--help]                   # this screen\n";

        print "\nFor further information type 'perldoc $0'\n";

    print "$0 v$VERSION\n";



CPAN Testers wouldn't exist without the help and support of the Perl 
community. However, since 2008 CPAN Testers has grown far beyond the 
expectations of it's original creators. As a consequence it now requires
considerable funding to help support the infrastructure.

In early 2012 the Enlightened Perl Organisation very kindly set-up a
CPAN Testers Fund within their donatation structure, to help the project
cover the costs of servers and services.

If you would like to donate to the CPAN Testers Fund, please follow the link
below to the Enlightened Perl Organisation's donation site.


If your company would like to support us, you can donate financially via the
fund link above, or if you have servers or services that we might use, please
send an email to admin@cpantesters.org with details.

Our full list of current sponsors can be found at our I <3 CPAN Testers site.



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 dependent upon their severity and my availability. Should a fix not
be forthcoming, please feel free to (politely) remind me.

RT Queue -

=head1 SEE ALSO



=head1 AUTHOR

  Barbie, <barbie@cpan.org>
  for Miss Barbell Productions <http://www.missbarbell.co.uk>.


  Copyright (C) 2005-2013 Barbie for Miss Barbell Productions.

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