line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Csistck::Term; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
268
|
use 5.010; |
|
17
|
|
|
|
|
50
|
|
4
|
17
|
|
|
17
|
|
71
|
use strict; |
|
17
|
|
|
|
|
23
|
|
|
17
|
|
|
|
|
334
|
|
5
|
17
|
|
|
17
|
|
64
|
use warnings; |
|
17
|
|
|
|
|
22
|
|
|
17
|
|
|
|
|
431
|
|
6
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
70
|
use base 'Exporter'; |
|
17
|
|
|
|
|
25
|
|
|
17
|
|
|
|
|
1221
|
|
8
|
|
|
|
|
|
|
|
9
|
17
|
|
|
17
|
|
8412
|
use Term::ReadKey; |
|
17
|
|
|
|
|
31339
|
|
|
17
|
|
|
|
|
1391
|
|
10
|
17
|
|
|
17
|
|
116
|
use Csistck::Test; |
|
17
|
|
|
|
|
29
|
|
|
17
|
|
|
|
|
685
|
|
11
|
17
|
|
|
17
|
|
143
|
use Csistck::Test::Return; |
|
17
|
|
|
|
|
38
|
|
|
17
|
|
|
|
|
7623
|
|
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; |