#!/usr/bin/perl
use strict;
use warnings;
use KiokuDB;
use Try::Tiny;
unless ( try_run() ) {
if ( $INC{"KiokuDB/Cmd.pm"} ) {
print "KiokuDB::Cmd is not up to date ($KiokuDB::REQUIRED_CMD_VERSION is required, $KiokuDB::Cmd::VERSION installed)\n";
} else {
print "KiokuDB::Cmd is not installed (it's now shipped in a separate distribution).\n";
}
try_auto_install();
}
print "\nPlease install an up to date KiokuDB::Cmd from CPAN\n";
exit 1;
sub try_run {
return unless try { require KiokuDB::Cmd; 1 };
return unless KiokuDB::Cmd->is_up_to_date;
KiokuDB::Cmd->run;
exit;
}
sub try_auto_install {
if (try {
require Module::AutoInstall;
require ExtUtils::MakeMaker;
1;
}) {
print "\n";
if ( ExtUtils::MakeMaker::prompt("Module::AutoInstall is available. Should I use it to install KiokuDB::Cmd?", "N/y") =~ /^y/i ) {
my @installed = Module::AutoInstall->install( [], "KiokuDB::Cmd" => $KiokuDB::REQUIRED_CMD_VERSION );
print "\n\n";
print "Please retry running your command :)\n";
exit 1;
}
}
return;
}