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

use base 'Reply::Plugin';

=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

sub new {
    my $class = shift;
    my $self = $class->SUPER::new(@_);
    $self->{counter} = 0;
    return $self;
}

sub prompt {
    my $self = shift;
    my ($next) = @_;
    return $self->{counter} . $next->();
}

sub loop {
    my $self = shift;
    my ($continue) = @_;
    $self->{counter}++;
    $continue;
}

1;