#!/usr/bin/perl

use warnings;
use strict;

use CPANPLUS::Backend;
use Pod::Usage;
use Cwd;

eval { require CPANPLUS::Dist::Arch; }
    or die "error: CPANPLUS::Dist::Arch must be installed for this script to work.\n";

my $cb      = CPANPLUS::Backend->new;

my @modnames = grep { /\A[\w:]+\z/ } @ARGV;
pod2usage() unless ( @modnames );

MODULE_ARG:
for my $modname ( @modnames ) {
    my $modobj = $cb->module_tree( $modname )
        or next MODULE_ARG;

    $modobj->install( target  => 'create',
                      format  => 'CPANPLUS::Dist::Arch',
                      verbose => 1,
                      pkg     => 'src',
                      destdir => getcwd() );
}

__END__

=head1 NAME

cpan2aur - Generate an AUR source package of a CPAN perl module

=head1 SYNOPSIS

cpan2aur Module::Name [ ... Module::Name ]

=head1 DESCRIPTION

Example script for using the advanced options of
L<CPANPLUS::Dist::Arch>.  Creates a source package in the current
working directory of each module passed as arguments.

=head1 AUTHOR

Justin Davis, C<< <jrcd83 at gmail dot com> >>, juster on
L<http://bbs.archlinux.org>

=head1 COPYRIGHT & LICENSE

Copyright 2009 Justin Davis, all rights reserved.

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

=cut
