summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/FancyPrompt.pm
blob: c074bff16dc498ff2a31701e79250c46c3ba9921 (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
package main;
use strict;
use warnings;
# ABSTRACT: provides a more informative prompt

use mop;

=head1 SYNOPSIS

  ; .replyrc
  [FancyPrompt]

=head1 DESCRIPTION

This plugin enhances the default Reply prompt. Currently, the only difference
is that it includes a counter of the number of lines evaluated so far in the
current session.

=cut

class Reply::Plugin::FancyPrompt extends Reply::Plugin {
    has $counter  = 0;
    has $prompted = 0;

    method prompt ($next) {
        $prompted = 1;
        return $counter . $next->();
    }

    method loop ($continue) {
        $counter++ if $prompted;
        $prompted = 0;
        $continue;
    }
}

1;