--- /dev/null
+use strict;
+use warnings;
+use inc::Module::Install 0.67;
+
+name 'Devel-REPL';
+all_from 'lib/Devel/REPL.pm';
+
+install_script 'script/re.pl';
+
+requires 'Moose';
+requires 'MooseX::Object::Pluggable';
+requires 'namespace::clean';
+requires 'File::HomeDir';
+requires 'File::Spec';
+requires 'Term::ReadLine';
+
+auto_install;
+WriteAll;
use Term::ReadLine;
use Moose;
use namespace::clean -except => [ 'meta' ];
+use 5.8.1; # might work with earlier perls but probably not
+
+our $VERSION = '1.000000';
with 'MooseX::Object::Pluggable';
sub print {
my ($self, @ret) = @_;
my $fh = $self->out_fh;
+ no warnings 'uninitialized';
print $fh "@ret";
}
+=head1 NAME
+
+Devel::REPL - a modern perl interactive shell
+
+=head1 SYNOPSIS
+
+ my $repl = Devel::REPL->new;
+ $repl->load_plugin($_) for qw(History LexEnv);
+ $repl->run
+
+Alternatively, use the 're.pl' script installed with the distribution
+
+=head1 AUTHOR
+
+Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>)
+
+=head1 LICENSE
+
+This library is free software under the same terms as perl itself
+
+=cut
+
1;
--- /dev/null
+package Devel::REPL::Script;
+
+use Moose;
+use Devel::REPL;
+use File::HomeDir;
+use File::Spec;
+use namespace::clean -except => [ qw(meta) ];
+
+with 'MooseX::Getopt';
+
+has 'rcfile' => (
+ is => 'ro', isa => 'Str', required => 1, default => sub { 'repl.rc' },
+);
+
+has '_repl' => (
+ is => 'ro', isa => 'Devel::REPL', required => 1,
+ default => sub { Devel::REPL->new() }
+);
+
+sub BUILD {
+ my ($self) = @_;
+ $self->load_rcfile;
+}
+
+sub load_rcfile {
+ my ($self) = @_;
+
+ my $rc_file = $self->rcfile;
+
+ # plain name => ~/.re.pl/${rc_file}
+ if ($rc_file !~ m!/!) {
+ $rc_file = File::Spec->catfile(File::HomeDir->my_home, '.re.pl', $rc_file);
+ }
+
+ if (-r $rc_file) {
+ open RCFILE, '<', $rc_file || die "Couldn't open ${rc_file}: $!";
+ my $rc_data;
+ { local $/; $rc_data = <RCFILE>; }
+ close RCFILE; # Don't care if this fails
+ $self->eval_rcdata($rc_data);
+ warn "Error executing rc file ${rc_file}: $@\n" if $@;
+ }
+}
+
+sub eval_rcdata {
+ my $_REPL = $_[0]->_repl;
+ eval $_[1];
+}
+
+sub run {
+ my ($self) = @_;
+ $self->_repl->run;
+}
+
+sub import {
+ my ($class, @opts) = @_;
+ return unless (@opts == 1 && $opts[0] eq 'run');
+ $class->new_with_options->run;
+}
+
+1;
--- /dev/null
+#!/usr/bin/env perl
+
+use lib 'lib';
+use Devel::REPL::Script 'run';
+
+#my $repl = Devel::REPL->new;
+
+#$repl->load_plugin('History');
+#$repl->load_plugin('LexEnv');
+#$repl->run;