line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# terminal::control Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::Terminal::Control; |
7
|
1
|
|
|
1
|
|
515
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base qw(Metabrik::Shell::Command Metabrik::System::Package); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
422
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
attributes => { |
19
|
|
|
|
|
|
|
output => [ qw(file) ], |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
commands => { |
22
|
|
|
|
|
|
|
install => [ ], # Inherited |
23
|
|
|
|
|
|
|
title => [ qw(string) ], |
24
|
|
|
|
|
|
|
record => [ qw(command|OPTIONAL) ], |
25
|
|
|
|
|
|
|
replay => [ qw(script_file timing_file|OPTIONAL) ], |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
require_binaries => { |
28
|
|
|
|
|
|
|
'script' => [ ], |
29
|
|
|
|
|
|
|
'scriptreplay' => [ ], |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
need_packages => { |
32
|
|
|
|
|
|
|
ubuntu => [ qw(bsdutils) ], |
33
|
|
|
|
|
|
|
debian => [ qw(bsdutils) ], |
34
|
|
|
|
|
|
|
kali => [ qw(bsdutils) ], |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub title { |
40
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
41
|
0
|
|
|
|
|
|
my ($title) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('title', $title) or return; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
print "\c[];$title\a\e[0m"; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $title; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub record { |
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
52
|
0
|
|
|
|
|
|
my ($output, $command) = @_; |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('record', $output) or return; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $cmd = 'script'; |
57
|
0
|
0
|
|
|
|
|
if (defined($command)) { |
58
|
0
|
|
|
|
|
|
$cmd .= " -c \"$command\""; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $script_file = "$output.script"; |
62
|
0
|
|
|
|
|
|
my $timing_file = "$output.timing"; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$cmd .= " -t\"$timing_file\" \"$script_file\""; |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
$self->system($cmd) or return; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return [ $script_file, $timing_file ]; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub replay { |
72
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my ($script, $timing) = @_; |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg('replay', $script) or return; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $cmd = 'scriptreplay'; |
78
|
0
|
0
|
|
|
|
|
if (defined($timing)) { |
79
|
0
|
|
|
|
|
|
$cmd .= " -t $timing"; |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
$cmd .= " $script"; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
return $self->execute($cmd); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |