| 1 | # | ||
| 2 | # $Id$ | ||
| 3 | # | ||
| 4 | # terminal::control Brik | ||
| 5 | # | ||
| 6 | package Metabrik::Terminal::Control; | ||
| 7 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | ▶ | use base qw(Metabrik::Shell::Command Metabrik::System::Package); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | sub brik_properties { | ||
| 13 | return { | ||
| 14 | revision => '$Revision$', | ||
| 15 | tags => [ qw(unstable) ], | ||
| 16 | author => 'GomoR <GomoR[at]metabrik.org>', | ||
| 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 | my $self = shift; | ||
| 41 | my ($title) = @_; | ||
| 42 | |||
| 43 | $self->brik_help_run_undef_arg('title', $title) or return; | ||
| 44 | |||
| 45 | print "\c[];$title\a\e[0m"; | ||
| 46 | |||
| 47 | return $title; | ||
| 48 | } | ||
| 49 | |||
| 50 | sub record { | ||
| 51 | my $self = shift; | ||
| 52 | my ($output, $command) = @_; | ||
| 53 | |||
| 54 | $self->brik_help_run_undef_arg('record', $output) or return; | ||
| 55 | |||
| 56 | my $cmd = 'script'; | ||
| 57 | if (defined($command)) { | ||
| 58 | $cmd .= " -c \"$command\""; | ||
| 59 | } | ||
| 60 | |||
| 61 | my $script_file = "$output.script"; | ||
| 62 | my $timing_file = "$output.timing"; | ||
| 63 | |||
| 64 | $cmd .= " -t\"$timing_file\" \"$script_file\""; | ||
| 65 | |||
| 66 | $self->system($cmd) or return; | ||
| 67 | |||
| 68 | return [ $script_file, $timing_file ]; | ||
| 69 | } | ||
| 70 | |||
| 71 | sub replay { | ||
| 72 | my $self = shift; | ||
| 73 | my ($script, $timing) = @_; | ||
| 74 | |||
| 75 | $self->brik_help_run_undef_arg('replay', $script) or return; | ||
| 76 | |||
| 77 | my $cmd = 'scriptreplay'; | ||
| 78 | if (defined($timing)) { | ||
| 79 | $cmd .= " -t $timing"; | ||
| 80 | } | ||
| 81 | $cmd .= " $script"; | ||
| 82 | |||
| 83 | return $self->execute($cmd); | ||
| 84 | } | ||
| 85 | |||
| 86 | 1; | ||
| 87 | |||
| 88 | __END__ | ||