#!/usr/bin/env perl

# cpanel - scripts/ppk-deptool                    Copyright(c) 2013 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use strict;
use warnings;

use App::PPK::Deptool ();

=head1 NAME

ppk-deptool - Perl Packager dependency tool

=head1 SYNOPSIS

    ~$ ppk-deptool list-targets
    some-program

    ~$ ppk-deptool list-target-deps some-program
    Some-Module-0.0.tar.gz

    ~$ ppk-deptool fetch-dist Some-Module-0.0.tar.gz

    ~$ ppk-deptool fetch-dist --deps-for some-program

=head1 DESCRIPTION

ppk-deptool provides support for managing dependencies for self-contained
programs in a manner that aids in the creation of a Makefile for easy building.
ppk-deptool is able to reference a C<PROG.INDEX>, as well as a C<DIST.INDEX>
file, which are used to represent lists of programs and their Perl package
depenencies, as well as how to fetch said dependencies from a remote source.

=head1 ARGUMENTS

=over

=item I<list-targets>

Open the C<PROG.INDEX> file in the current directory and list all build targets
therein, one per line.

=item I<list-target-deps> C<target>

Given a target listed in C<PROG.INDEX>, list all the Perl package dependencies
needed to build that target.

=item I<fetch-dist> C<dist>

Given a Perl package distribution listed in C<DIST.INDEX>, fetch the Perl
package distribution and place it in the current working directory.

=item I<fetch-dist> C<--deps-for> C<target>

Given a target listed in C<PROG.INDEX>, fetch all dependencies from each source
listed in C<DIST.INDEX>.

=back

=head1 PROG.INDEX

The C<PROG.INDEX> file is a flat file formatted in the following manner.

    program-a: Some-Dep-0.1.tar.gz Another-Dep-1.0.tar.gz
    program-b: Some-Dep-0.1.tar.gz Acme-Eyebleach-1.0.tar.gz

Lines can consist solely of whitespace, or begin with a hash (#) to begin a
comment.  Any number of whitespace-delimited distribution names can be listed as
dependencies for a target program.  Dependencies should have a corresponding
definition in L<DIST.INDEX>.

=head1 DIST.INDEX

The C<DIST.INDEX> file is a flat file which lists all available Perl package
distribution dependencies for a project, as well as a single URI from which each
may be obtained.  Entries may be listed as such:

    #
    # Tarball via HTTP
    #
    Another-Dep-1.0.tar.gz: http://foo.bar/baz/Another-Dep-1.0.tar.gz

    #
    # Tarball via HTTP via CPAN
    #
    Acme-Eyebleach-1.0.tar.gz: cpan://SOMEBODY/Acme-Eyebleach-1.0.tar.gz

    #
    # Repository via git
    #
    Yet-Another-1.0: git://foo.bar/baz/Yet-Another

Empty lines containing only whitespace, or beginning with any amount of
whitespace, or none at all, followed by a hash (#) to denote a comment, are
permitted.

=cut

App::PPK::Deptool->run(@ARGV);

__END__

=head1 COPYRIGHT

Copyright (c) 2013, cPanel, Inc.  All rights reserved.  This is free software;
you can redistribute it and/or modify it under the same terms as Perl itself.
See L<perlartistic> for further details.
