line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Reply::Plugin::ConfigurablePrompt; |
2
|
1
|
|
|
1
|
|
1172
|
use parent qw(Reply::Plugin); |
|
1
|
|
|
|
|
284
|
|
|
1
|
|
|
|
|
5
|
|
3
|
1
|
|
|
1
|
|
10338
|
use 5.008005; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
19
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
209
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $history_count = 0; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
13
|
0
|
|
|
|
|
|
my %opts = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
16
|
0
|
|
|
|
|
|
$self->{prompt_string} = $opts{prompt}; |
17
|
0
|
|
|
|
|
|
*main::history_count = \$history_count; |
18
|
0
|
|
|
|
|
|
$self->{prompted} = 0; |
19
|
0
|
|
|
|
|
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub prompt { |
23
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
24
|
0
|
|
|
|
|
|
my ($next) = @_; |
25
|
0
|
|
|
|
|
|
$self->{prompted} = 1; |
26
|
0
|
|
|
|
|
|
my $result = ""; |
27
|
0
|
|
|
|
|
|
my $prompt = $self->{prompt_string}; |
28
|
0
|
0
|
|
|
|
|
if ( $prompt ) { |
29
|
|
|
|
|
|
|
package main; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
$result = eval "$prompt" if ( $prompt ); |
32
|
0
|
0
|
|
|
|
|
die $@ if ( $@ ); |
33
|
|
|
|
|
|
|
} |
34
|
0
|
0
|
|
|
|
|
return $result ? $result # configured prompt |
35
|
|
|
|
|
|
|
: $history_count . $next->(); # default prompt |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub loop { |
39
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
40
|
0
|
|
|
|
|
|
my ($continue) = @_; |
41
|
0
|
0
|
|
|
|
|
$history_count++ if ( $self->{prompted} ); |
42
|
0
|
|
|
|
|
|
$self->{prompted} = 0; |
43
|
0
|
|
|
|
|
|
$continue; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=encoding utf-8 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=for stopwords configurable |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Reply::Plugin::ConfigurablePrompt - Configurable prompt for reply |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
; in your .replyrc use following instead of [FancyPrompt] (or other prompt plugin) |
62
|
|
|
|
|
|
|
[ConfigurablePrompt] |
63
|
|
|
|
|
|
|
prompt="reply $history_count $ " |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 DESCRIPTION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Reply::Plugin::ConfigurablePrompt is plugin for Reply. This plugin provides configurable prompt. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NOTE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This plugin is exclusive to other prompt plugin. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 HOW TO CUSTOMIZE |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
You can use any perl syntax in prompt section. variables and functions are usable if these are exported in main package. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 EXPORTED VARIABLES |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 $history_count |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
the history number of this command |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Copyright (C) Takuya Tsuchida. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
88
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Takuya Tsuchida E<lt>tsucchi@cpan.orgE<gt> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|