Sha256: f22ed83a16e9d67020246cd4c35152c8810ed4356bbe8f463a71b23b5bd10755

Contents?: true

Size: 841 Bytes

Versions: 2

Compression:

Stored size: 841 Bytes

Contents

#!/usr/bin/env perl

# Example: ./install.pl Acme::please

sub usage {
  my($message) = @_;
  print <<EOB;
usage: install.pl [--quiet|--help|--dryrun] module [modules...]
EOB
  if ($message) {
    print "ERROR: $message\n";
    exit 1;
  } else {
    exit 0;
  }
}

use warnings "all";
use CPAN;
use Getopt::Long;

our $quiet = 0;
our $dryrun = 0;
our $help = 0;
GetOptions(
  'quiet' => \$quiet,
  'dryrun' => \$dryrun,
  'n' => \$dryrun,
  'help' => \$help
);

if (1 == $help) {
  usage(0);
}

@modules = @ARGV;
unless ($#modules >= 0) {
  usage "No modules specified";
}

foreach my $module (@modules) {
  if (my $module_ref = CPAN::Shell->expand('Module', $module)) {
    print "* Installing: $module\n" unless $quiet;
    $module_ref->install unless $dryrun;
  } else {
    print "! Can't find CPAN module: $module\n";
    exit 1
  }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
automateit-0.71220 helpers/cpan_install.pl
automateit-0.71221 helpers/cpan_install.pl