#!/usr/bin/perl
BEGIN {
$VERSION
=
'0.02'
;
$| = 1;
}
BEGIN {
eval
"use Smart::Comments;"
}
my
$VERBOSE
= 0;
my
$NEWEST
= 0;
my
$MERGED
= 0;
Getopt::Long::GetOptions(
"verbose+"
=> \
$VERBOSE
,
"newest"
=> \
$NEWEST
,
"merged"
=> \
$MERGED
,
);
$NEWEST
= 1
if
$MERGED
;
my
$root
=
defined
$ARGV
[0]
?
shift
(
@ARGV
)
: File::Spec->curdir;
print
"Searching for dists... "
;
my
$collection
= Module::Collection->new(
root
=>
$root
);
my
$found
=
$collection
->dists
or
die
"$root does not contain any distributions"
;
print
"found $found\n"
;
my
@dists
=
$collection
->dists;
if
(
$NEWEST
or
$VERBOSE
or
$MERGED
) {
foreach
(
@dists
) {
$collection
->dist(
$_
);
}
}
$collection
->ignore_old_dists
if
$NEWEST
;
print
"\n"
;
foreach
my
$file
(
$collection
->dists ) {
unless
(
$VERBOSE
) {
print
"$file\n"
;
next
;
}
my
$dist
=
$collection
->dist(
$file
);
print
"\n"
;
print
"$file\n"
;
print
" Name: "
.
$dist
->dist_name .
"\n"
;
print
" Version: "
.
$dist
->dist_version .
"\n"
;
if
(
$VERBOSE
>= 2 ) {
my
$requires
=
$dist
->dist_requires;
if
(
keys
%$requires
) {
print
" Requires:\n"
;
foreach
(
sort
keys
%$requires
) {
print
" $_: $requires->{$_}\n"
;
}
}
else
{
print
" Requires: Nothing\n"
;
}
my
$build_requires
=
$dist
->dist_build_requires;
if
(
keys
%$build_requires
) {
print
" Build Requires:\n"
;
foreach
(
sort
keys
%$build_requires
) {
print
" $_: $build_requires->{$_}\n"
;
}
}
else
{
print
" Build Requires: Nothing\n"
;
}
}
}
if
(
$MERGED
) {
print
"\n"
;
print
"Listing Merged Depencies:\n"
;
my
$merged
=
$collection
->depends;
print
$merged
->as_string;
}
exit
(0);