#!perl
use strict;
use Getopt::Long qw(:config pass_through);
use Pod::Usage;
require App::perlbrew;

my $opt = {
    force => undef,
    quiet => 1,
    D     => [],
};
GetOptions(
    'f|force!'  => \$opt->{force},
    'q|quiet!'  => \$opt->{quiet},
    'v|verbose' => \$opt->{verbose},
    'as=s'      => \$opt->{as},
    'D|D=s@'    => $opt->{D},
    'help|?'    => sub { pod2usage(1) },
) or pod2usage(2);
App::perlbrew->run_command( $opt, @ARGV );

__END__

=head1 NAME

perlbrew - Perl Environment manager.

=head1 SYNOPSIS

    perlbrew [options] [init|install|installed|switch]

    # Initialize
    perlbrew init

    # Pick a prefered CPAN mirror
    perlbrew mirror 

    # Install some Perls
    perlbrew install perl-5.12.0
    perlbrew install perl-5.13.0

    # Install from a git checkout
    cd /path/to/src/perl
    perlbrew install .

    # List which perls are installed
    perlbrew installed

    # Switch perl in the $PATH
    # hash -r clears the PATH cache
    perlbrew switch perl-5.13.0
    hash -r 
    perl -v

    # Turn it off. Disable it.
    perlbrew off

    # Turn it back on. Re-enable it.
    perlbrew switch perl-5.13.0

=head1 CONFIGURATION

By default perlbrew builds and installs copies of perl into
C<$ENV{HOME}/perl5/perlbrew>. To use a different directory, set the
C<PERLBREW_ROOT> shell variable before running perlbrew.

=head1 COMMANDS

=over 4

=item init

Run this once to setup the C<perlbrew> directory ready for installing
perls into. Run it again if you decide to change C<PERLBREW_ROOT>.

=item mirror

Run this if you want to choose a specific CPAN mirror to install the
perls from. It will display a list of mirrors for you to pick
from. Hit 'q' to cancel the selection.

=item install perl-<version>

Build and install the given version of perl.

=item install /path/to/perl/git/checkout/dir

Build and install from the given git checkout dir.

=item installed

List the installed versions of perl.

=item switch perl-<version>

Switch to the given version. You may need to run 'rehash' (or 'hash
-r') after this command.

=item off

Disable perlbrew. Use C<switch> command to re-enable it. Use 'rehash'
or 'hash -r' again to clear the cache.

=head1 OPTIONS

=over 4

=item B<-?|help>

prints this help.

=item B<-f|force>

Force installation of a perl.

=item B<-q|quiet>

Log output to a log file rather than STDOUT. This is the default. The log file is saved in F<$ROOT/build.log>

=item B<-v|verbose>

Log output to STDOUT rather than a logfile.

=item B<-as>

Install a given perl under an alias. 

    perlbrew install perl-5.6.2 -as legacy-perl

=item B<-D>

pass through switches to the perl Configure script.

    perlbrew install perl-5.10.1 -D=usemymalloc

=back

=head1 DESCRIPTION

Read L<App::perlbrew> for more complete documentation.

=cut
