blob: 9965e84e06054d17c3b6656e71420122004718d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/usr/bin/env perl
use MetaCPAN::Client;
use feature 'say';
my $mc = MetaCPAN::Client->new;
my %commands = (
pod => sub {
say $mc->pod(shift)->plain;
},
url => sub {
say $mc->download_url(shift)->download_url;
},
describe => sub {
say $mc->module(shift)->abstract;
},
src => sub {
say $mc->module(shift)->source;
},
);
die "Usage: $0 <${\join '|',keys %commands}> [MODULE]" unless @ARGV;
my $command = shift;
die "No such command: $command" unless exists $commands{$command};
if (@ARGV == 0 or $ARGV[0] eq '-') {
while (<STDIN>) {
chomp;
next if /^$/;
$commands{$command}->($_);
}
} else {
$commands{$command}->($_) for @ARGV;
}
|