summaryrefslogtreecommitdiff
path: root/mcpan
diff options
context:
space:
mode:
authorNick Shipp <nick@shipp.ninja>2017-06-03 01:33:15 -0400
committerNick Shipp <nick@shipp.ninja>2017-06-03 01:33:15 -0400
commit40f17d1f4bd03c48cb89a6e70e9cd7a3259334c6 (patch)
tree5984140fe779d76aac734bf0cc1474c2a03bddce /mcpan
Initial commitHEADmaster
Diffstat (limited to 'mcpan')
-rwxr-xr-xmcpan35
1 files changed, 35 insertions, 0 deletions
diff --git a/mcpan b/mcpan
new file mode 100755
index 0000000..9965e84
--- /dev/null
+++ b/mcpan
@@ -0,0 +1,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;
+}