line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Csistck::Term; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
277
|
use 5.010; |
|
17
|
|
|
|
|
91
|
|
|
17
|
|
|
|
|
659
|
|
4
|
17
|
|
|
17
|
|
133
|
use strict; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
500
|
|
5
|
17
|
|
|
17
|
|
79
|
use warnings; |
|
17
|
|
|
|
|
98
|
|
|
17
|
|
|
|
|
455
|
|
6
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
142
|
use base 'Exporter'; |
|
17
|
|
|
|
|
31
|
|
|
17
|
|
|
|
|
1220
|
|
8
|
|
|
|
|
|
|
|
9
|
17
|
|
|
17
|
|
676805
|
use Term::ReadKey; |
|
17
|
|
|
|
|
132503
|
|
|
17
|
|
|
|
|
1831
|
|
10
|
17
|
|
|
17
|
|
185
|
use Csistck::Test; |
|
17
|
|
|
|
|
44
|
|
|
17
|
|
|
|
|
1008
|
|
11
|
17
|
|
|
17
|
|
104
|
use Csistck::Test::Return; |
|
17
|
|
|
|
|
34
|
|
|
17
|
|
|
|
|
9155
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ |
14
|
|
|
|
|
|
|
prompt |
15
|
|
|
|
|
|
|
/; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Interactive terminal prompt. Takes in test as argument, and displays action |
18
|
|
|
|
|
|
|
# options |
19
|
|
|
|
|
|
|
sub prompt { |
20
|
0
|
|
|
0
|
0
|
|
my $test = shift; |
21
|
0
|
|
|
|
|
|
my %options; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Ask question loop, get input. If choices are not code refs, do not show choice |
24
|
0
|
|
|
|
|
|
say("What would you like to:"); |
25
|
0
|
|
|
|
|
|
my @choices = (); |
26
|
|
|
|
|
|
|
# Repair |
27
|
0
|
0
|
|
|
|
|
if ($test->can('repair')) { |
28
|
0
|
|
|
|
|
|
say(" Y : Repair"); |
29
|
0
|
|
|
|
|
|
push(@choices, 'Y'); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
# Skip |
32
|
0
|
|
|
|
|
|
say(" N : Skip"); |
33
|
0
|
|
|
|
|
|
push(@choices, 'n'); |
34
|
|
|
|
|
|
|
# Diff |
35
|
0
|
0
|
|
|
|
|
if ($test->can('diff')) { |
36
|
0
|
|
|
|
|
|
say(" D : Diff"); |
37
|
0
|
|
|
|
|
|
push(@choices, 'd'); |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
|
print("[Y/n/d]? "); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
ReadMode 3; |
42
|
0
|
|
|
|
|
|
my $action = ReadKey(0); |
43
|
0
|
|
|
|
|
|
say($action); |
44
|
0
|
|
|
|
|
|
ReadMode 0; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Execute and return, based on input. Return value is used for processing |
47
|
|
|
|
|
|
|
# on_repair operations. |
48
|
0
|
|
|
|
|
|
given ($action) { |
49
|
0
|
|
|
|
|
|
when (/[Yy\n]/) { |
50
|
0
|
0
|
|
|
|
|
return $test->execute('repair') if ($test->can('repair')); |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
when (/[Dd]/) { |
53
|
|
|
|
|
|
|
# Show diff, loop through prompt again |
54
|
0
|
0
|
|
|
|
|
$test->execute('diff') if ($test->can('diff')); |
55
|
0
|
|
|
|
|
|
return prompt($test); |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
default { |
58
|
0
|
|
|
|
|
|
return Csistck::Test::Return->new( |
59
|
|
|
|
|
|
|
resp => 0, |
60
|
|
|
|
|
|
|
msg => 'Missing function', |
61
|
|
|
|
|
|
|
desc => $test->desc |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |