Allow Perl version to be specified
[perl-App-RetroPAN.git] / bin / retropan
blobbf8b6d88bacbe5a438b2392e8b14408f58ebda4c
1 #!/usr/bin/env perl
2 # vim:ts=4:shiftwidth=4:expandtab
4 use strict;
5 use warnings;
6 use utf8;
8 use Getopt::Long;
9 use Pod::Usage;
10 use DateTime;
11 use DateTime::Format::ISO8601;
12 use App::RetroPAN;
14 my $opt_man = 0;
15 my $opt_help = 0;
16 my $opt_dir = "minicpan/";
17 my $opt_version;
18 my $opt_before = DateTime->now->iso8601;
20 GetOptions(
21 'help|?' => \$opt_help,
22 man => \$opt_man,
23 "dir=s" => \$opt_dir,
24 "before=s" => \$opt_before,
25 version => \$opt_version,
26 ) or pod2usage(2);
27 pod2usage(1) if $opt_help;
28 pod2usage(-exitval => 0, -verbose => 2) if $opt_man;
30 if ($opt_version) {
31 print STDERR "Version $App::RetroPAN::VERSION\n";
32 exit 0;
35 die "No time specified" if !$opt_before;
37 my $dt = DateTime::Format::ISO8601->parse_datetime($opt_before);
39 print STDERR "No modules to find\n" if !@ARGV;
41 my ($dists_required, $dist_to_url) = App::RetroPAN::find_deps_on_date($dt->iso8601, @ARGV);
43 App::RetroPAN::make_minicpan($opt_dir, $dists_required, $dist_to_url);
45 exit 0;
47 =encoding utf8
49 =head1 NAME
51 retropan - Makes a historic minicpan ⏳
53 =head1 SYNOPSIS
55 $ retropan --dir minicpan/ --before 2011-02-01T00:00:00 Moose Catalyst
57 =head1 OPTIONS
59 The trailing arguments are the module names to be looked up.
61 =over
63 =item B<--before>
65 Search for distributions released before this data. Defaults to now.
68 =item B<--minicpan>
70 Path of where to place our minicpan. Defaults to C<minicpan/>.
72 =back
74 =head1 SEE ALSO
76 L<App::RetroPAN>
78 =head1 LICENSE
80 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
82 =head1 AUTHOR
84 Dave Lambley <dlambley@cpan.org>
86 =cut