summaryrefslogtreecommitdiffstats
path: root/lib/App/REPL/Plugin/Defaults.pm
blob: ecc221b46898cd54df12329faa08fdfbe6030bc1 (plain) (blame)
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
36
37
38
39
40
41
42
43
44
45
46
package App::REPL::Plugin::Defaults;

# don't pollute with strict and warnings for this module
sub _eval { eval($_[0]) }

use strict;
use warnings;

use base 'App::REPL::Plugin';

sub display_prompt {
    my $self = shift;

    print "> ";
}

sub read_line {
    my $self = shift;

    return scalar <>;
}

sub evaluate {
    my $self = shift;
    my ($next, $line) = @_;

    return _eval($line);
}

sub print_error {
    my $self = shift;
    my ($next, $error) = @_;

    print $error, "\n"
        if defined $error;
}

sub print_result {
    my $self = shift;
    my ($next, $result) = @_;

    print $result, "\n"
        if defined $result;
}

1;