summaryrefslogtreecommitdiffstats
path: root/lib/App/Ttyrec.pm
blob: 828556c06a5f54dd1a79c7857d1d4354a3e850ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package App::Ttyrec;
use Moose;
# ABSTRACT: record interactive terminal sessions

use Scalar::Util 'weaken';
use Tie::Handle::TtyRec 0.04;

with 'Term::Filter';

has ttyrec_file => (
    is      => 'ro',
    isa     => 'Str',
    default => 'ttyrecord',
);

has append => (
    is      => 'ro',
    isa     => 'Bool',
    default => 0,
);

has ttyrec => (
    is      => 'ro',
    isa     => 'FileHandle',
    lazy    => 1,
    default => sub {
        my $self = shift;
        Tie::Handle::TtyRec->new($self->ttyrec_file, append => $self->append)
    },
);

sub munge_output {
    my $self = shift;
    my ($got) = @_;

    syswrite $self->ttyrec, $got;

    $got;
}

__PACKAGE__->meta->make_immutable;
no Moose;

1;