LibTmux/Server.pm

filter: Statementstmt 50.8% 247 / 486 Branchbran 31.4% 108 / 344 Conditioncond 26.8% 75 / 279 MC/DCmcdc 9.8% 15 / 152 Subroutinesub 44.1% 53 / 120 Podpod 97.7% 43 / 44 totaltotal 37.9% 541 / 1425 CC 284 SCAR 57.0
CC
284
Cov
39%
_prepare
1261.2
_validate_options
609.1
_pane_command
196.1
CRAP 297.8
« LibTmux/Transport.pm ↑ Summary LibTmux/QueryPlan.pm »
1 package LibTmux::Server;
2 3 ▶use v5.44;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Time::HiRes qw(time);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use LibTmux;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use LibTmux::Operation;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use LibTmux::Transport;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use LibTmux::Codec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use LibTmux::Schema;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use LibTmux::Snapshot;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use LibTmux::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use LibTmux::X;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 5 ▶sub new ($class, %args) {
Subroutine new: called CC=16 SCAR=31.1
Pod documented
17 5 my %allowed = map { $_ => 1 }
18 qw(executable socket_name socket_path config_file timeout max_output env);
19 LibTmux::X::InvalidArgument->throw(message => "unknown server option $_")
20 5 for grep { !$allowed{$_} } keys %args;
21 LibTmux::X::InvalidArgument->throw(
22 message => 'socket_name and socket_path are exclusive')
23 5 ▶ if exists($args{socket_name}) && exists($args{socket_path});
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"socket_name"} and exists $args{"socket_path"} 0 5 5
Condition66%2/3
exists $args{"socket_name"} and exists $args{"socket_path"}
!ll&&!rl&&r
410
MC/DC0%0/2
exists $args{"socket_name"} and exists $args{"socket_path"}
exists $args{"socket_name"} exists $args{"socket_path"}
Truth table66%2/3
A and B
A= exists $args{"socket_name"}B= exists $args{"socket_path"}
ABresult
0X0
100
111
24 5 for my $key (qw(executable socket_name socket_path config_file)) {
25 20 ▶ next unless exists $args{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{$key} 18 2 20
26 LibTmux::X::InvalidArgument->throw(
27 message => "$key must be a nonempty NUL-free scalar")
28 if !defined($args{$key})
29 || ref($args{$key})
30 || !length($args{$key})
31 2 ▶ || $args{$key} =~ /\0/;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $args{$key} or ref $args{$key} or not length $args{$key} or $args{$key} =~ /\0/u 0 2 2
Condition33%3/9
not defined $args{$key} or ref $args{$key} or not length $args{$key} or $args{$key} =~ /\0/u
l!l&&r!l&&!r
002
not defined $args{$key} or ref $args{$key} or not length $args{$key}
l!l&&r!l&&!r
002
not defined $args{$key} or ref $args{$key}
l!l&&r!l&&!r
002
MC/DC0%0/4
not defined $args{$key} or ref $args{$key} or not length $args{$key} or $args{$key} =~ /\0/u
not defined $args{$key} ref $args{$key} not length $args{$key} $args{$key} =~ /\0/u
Truth table20%1/5
not(A) or B or not(C) or D
A= not defined $args{$key}B= ref $args{$key}C= not length $args{$key}D= $args{$key} =~ /\0/u
ABCDresult
1XXX1
01XX1
001X1
00011
00000
32 }
33 LibTmux::X::InvalidArgument->throw(
34 message => 'socket name cannot contain a slash')
35 5 ▶ if exists($args{socket_name}) && $args{socket_name} =~ m!/!;
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"socket_name"} and $args{"socket_name"} =~ m[/]u 0 5 5
Condition66%2/3
exists $args{"socket_name"} and $args{"socket_name"} =~ m[/]u
!ll&&!rl&&r
410
MC/DC0%0/2
exists $args{"socket_name"} and $args{"socket_name"} =~ m[/]u
exists $args{"socket_name"} $args{"socket_name"} =~ m[/]u
Truth table66%2/3
A and B
A= exists $args{"socket_name"}B= $args{"socket_name"} =~ m[/]u
ABresult
0X0
100
111
36 $args{socket_path} = File::Spec->rel2abs($args{socket_path})
37 5 ▶ if exists $args{socket_path};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"socket_path"} 0 5 5
38 5 %args = LibTmux::Transport->_configuration(%args);
39 4 $args{env} = {%{$args{env}}};
40 4 ▶ $args{executable} //= 'tmux';
Condition100%2/2
$args{"executable"} //= "tmux"
l!l
13
MC/DC100%1/1
$args{"executable"} //= "tmux"
$args{"executable"}
Truth table100%2/2
A
A= $args{"executable"}
Aresult
11
00
41 4 ▶ $args{timeout} //= 5;
Condition50%1/2
$args{"timeout"} //= 5
l!l
40
MC/DC0%0/1
$args{"timeout"} //= 5
$args{"timeout"}
Truth table50%1/2
A
A= $args{"timeout"}
Aresult
11
00
42 4 ▶ $args{max_output} //= 8 * 1024 * 1024;
Condition50%1/2
$args{"max_output"} //= 8388608
l!l
40
MC/DC0%0/1
$args{"max_output"} //= 8388608
$args{"max_output"}
Truth table50%1/2
A
A= $args{"max_output"}
Aresult
11
00
43 4 return bless \%args, $class;
44 }
45  
46 2 ▶sub _prefix ($self) {
Subroutine _prefix: called CC=4 SCAR=14.6
47 2 my @argv = ($self->{executable});
48 2 ▶ push @argv, ('-S', $self->{socket_path}) if exists $self->{socket_path};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"socket_path"} 0 2 2
49 2 ▶ push @argv, ('-L', $self->{socket_name}) if exists $self->{socket_name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"socket_name"} 2 0 2
50 2 ▶ push @argv, ('-f', $self->{config_file}) if exists $self->{config_file};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"config_file"} 0 2 2
51 2 return @argv;
52 }
53  
54 3 ▶sub _process_op ($self, $argv, %options) {
Subroutine _process_op: called CC=1 SCAR=0.0
55 LibTmux::Operation->request(
56 argv => $argv,
57 timeout => $self->{timeout},
58 max_output => $self->{max_output},
59 3 env => {%{$self->{env}}},
60 %options
61 );
62 }
63  
64 2 ▶sub _raw_op ($self, $argv, %options) {
Subroutine _raw_op: called CC=7 SCAR=22.7
65 2 ▶ LibTmux::X::InvalidArgument->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $argv eq "ARRAY" and @$argv 0 2 2
Condition33%1/3
ref $argv eq "ARRAY" and @$argv
!ll&&!rl&&r
002
MC/DC0%0/2
ref $argv eq "ARRAY" and @$argv
ref $argv eq "ARRAY" @$argv
Truth table33%1/3
A and B
A= ref $argv eq "ARRAY"B= @$argv
ABresult
0X0
100
111
66 message => 'argv must be a nonempty array')
67 unless ref($argv) eq 'ARRAY' && @$argv;
68 2 for (@$argv) {
69 8 ▶ LibTmux::X::InvalidArgument->throw(
Branch: 1 branch
BranchTrueFalseTotal
if not defined $_ or ref $_ or /\0/u 0 8 8
Condition33%2/6
not defined $_ or ref $_ or /\0/u
l!l&&r!l&&!r
008
not defined $_ or ref $_
l!l&&r!l&&!r
008
MC/DC0%0/3
not defined $_ or ref $_ or /\0/u
not defined $_ ref $_ /\0/u
Truth table25%1/4
not(A) or B or C
A= not defined $_B= ref $_C= /\0/u
ABCresult
1XX1
01X1
0011
0000
70 message => 'arguments must be defined NUL-free scalars')
71 if !defined($_) || ref($_) || /\0/;
72 }
73 2 my @literal = map { my $value = "$_"; $value =~ s/;\z/\\;/; $value } @$argv;
74  
75 # Preserve framing bytes even when the caller's locale is not UTF-8.
76 2 $self->_process_op([$self->_prefix, '-u', @literal], %options);
77 }
78  
79 13 ▶sub _checked ($self, $operation) {
Subroutine _checked: called CC=1 SCAR=3.5
80 $operation->then(
81 12 ▶ sub ($result) {
Subroutine __ANON__: called CC=5 SCAR=28.8
82 12 ▶ unless ($result->success) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($result->success) 0 12 12
83 0 my $message = $result->stderr;
84 0 $message =~ s/\n\z//;
85 0 ▶ my $type =
Branch: 1 branch
BranchTrueFalseTotal
$message =~ /no server running|server exited unexpectedly|(?:failed to connect|error connecting to).*(?:No such file or directory|Connection refused)/su ? : 0 0 0
86 $message =~
87 /no server running|server exited unexpectedly|(?:failed to connect|error connecting to).*(?:No such file or directory|Connection refused)/s
88 ? 'LibTmux::X::NoServer'
89 : 'LibTmux::X::Command';
90 0 ▶ $type = 'LibTmux::X::NoSuchTarget'
Branch: 1 branch
BranchTrueFalseTotal
if $message =~ /can't find (?:pane|window|session|client)|no such (?:pane|window|session|client)/u 0 0 0
91 if $message =~
92 /can't find (?:pane|window|session|client)|no such (?:pane|window|session|client)/;
93 0 ▶ $type->throw(
Condition0%0/2
$message || 'tmux command failed'
l!l
00
MC/DC0%0/1
$message || 'tmux command failed'
$message
Truth table0%0/2
A
A= $message
Aresult
11
00
94 message => $message || 'tmux command failed',
95 result => $result,
96 dispatched => true
97 );
98 }
99 12 return $result;
100 }
101 13 );
102 }
103  
104 2 ▶sub _cmd_op ($self, $argv, %options) {
Subroutine _cmd_op: called CC=1 SCAR=0.0
105 2 $self->_checked($self->_raw_op($argv, %options));
106 }
107  
108 2 ▶sub at_least ($class, $version, $minimum) {
Subroutine at_least: called CC=1 SCAR=0.0
Pod undocumented
109 2 LibTmux::Schema->_version_at_least($version, $minimum);
110 }
111  
112 1 ▶sub _binary_op ($self) {
Subroutine _binary_op: called CC=2 SCAR=7.1
113 return LibTmux::Operation->value($self->{binary_version})
114 1 ▶ if $self->{binary_version};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"binary_version"} 0 1 1
115 return $self->_checked($self->_process_op([$self->{executable}, '-V']))
116 ->then(
117 1 ▶ sub ($result) {
Subroutine __ANON__: called CC=2 SCAR=7.0
118 1 my $version = $result->stdout;
119 1 $version =~ s/\s+\z//;
120 1 ▶ LibTmux::X::Unsupported->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless $self->at_least($version, "3.3a") 0 1 1
121 message => "tmux 3.3a or newer required; found $version")
122 unless $self->at_least($version, '3.3a');
123 1 $self->{binary_version} = $version;
124 1 return $version;
125 }
126 1 );
127 }
128  
129 1 ▶sub _identity_op ($self) {
Subroutine _identity_op: called CC=1 SCAR=0.2
130 1 my @fields = qw(socket_path pid start_time version);
131 1 my $format = LibTmux::Codec->format(@fields);
132 return $self->_cmd_op(['display-message', '-p', $format])->then(
133 1 ▶ sub ($result) {
Subroutine __ANON__: called CC=6 SCAR=19.9
134 1 my $rows = LibTmux::Codec->decode($result->stdout, scalar @fields);
135 1 ▶ LibTmux::X::Codec->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless @$rows == 1 0 1 1
136 message => 'expected one server identity row')
137 unless @$rows == 1;
138 1 my %identity;
139 1 @identity{@fields} = $rows->[0]->@*;
140 LibTmux::X::Codec->throw(message => 'invalid daemon identity')
141 unless $identity{pid} =~ /\A[1-9][0-9]*\z/
142 && $identity{start_time} =~ /\A[0-9]+\z/
143 1 ▶ && length $identity{socket_path};
Branch: 1 branch
BranchTrueFalseTotal
unless $identity{"pid"} =~ /\A[1-9][0-9]*\z/u and $identity{"start_time"} =~ /\A[0-9]+\z/u and length $identity{"socket_path"} 0 1 1
Condition33%2/6
$identity{"pid"} =~ /\A[1-9][0-9]*\z/u and $identity{"start_time"} =~ /\A[0-9]+\z/u and length $identity{"socket_path"}
!ll&&!rl&&r
001
$identity{"pid"} =~ /\A[1-9][0-9]*\z/u and $identity{"start_time"} =~ /\A[0-9]+\z/u
!ll&&!rl&&r
001
MC/DC0%0/3
$identity{"pid"} =~ /\A[1-9][0-9]*\z/u and $identity{"start_time"} =~ /\A[0-9]+\z/u and length $identity{"socket_path"}
$identity{"pid"} =~ /\A[1-9][0-9]*\z/u $identity{"start_time"} =~ /\A[0-9]+\z/u length $identity{"socket_path"}
Truth table25%1/4
A and B and C
A= $identity{"pid"} =~ /\A[1-9][0-9]*\z/uB= $identity{"start_time"} =~ /\A[0-9]+\z/uC= length $identity{"socket_path"}
ABCresult
0XX0
10X0
1100
1111
144 LibTmux::X::Unsupported->throw(
145 message => 'connected daemon is below tmux 3.3a')
146 1 ▶ unless $self->at_least($identity{version}, '3.3a');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->at_least($identity{"version"}, "3.3a") 0 1 1
147 1 $identity{server_id} = $identity{socket_path};
148 1 $identity{generation} = "$identity{pid}/$identity{start_time}";
149 1 return \%identity;
150 }
151 1 );
152 }
153  
154 0 ▶sub _list_op ($self, $kind, $version) {
Subroutine _list_op: not called CC=6 SCAR=37.4
155 0 my %commands = (
156 session => ['list-sessions'],
157 window => ['list-windows', '-a'],
158 pane => ['list-panes', '-a'],
159 client => ['list-clients']
160 );
161 LibTmux::X::InvalidArgument->throw(
162 message => 'listing kind must be session/window/pane/client')
163 0 ▶ unless $commands{$kind};
Branch: 1 branch
BranchTrueFalseTotal
unless $commands{$kind} 0 0 0
164 0 my $schema = LibTmux::Schema->entity($kind)->{fields};
165 my @keys = sort grep {
166 0 $schema->{$_}{source}
167 && $self->at_least($version, $schema->{$_}{minimum})
168 0 ▶ } keys %$schema;
Condition0%0/3
$schema->{$_}{'source'} && $self->at_least($version, $schema->{$_}{'minimum'})
!ll&&!rl&&r
000
MC/DC0%0/2
$schema->{$_}{'source'} && $self->at_least($version, $schema->{$_}{'minimum'})
$schema->{$_}{'source'} $self->at_least($version, $schema->{$_}{'minimum'})
Truth table0%0/3
A && B
A= $schema->{$_}{'source'}B= $self->at_least($version, $schema->{$_}{'minimum'})
ABresult
0X0
100
111
169 0 my @tokens = map { $schema->{$_}{source} } @keys;
170 0 ▶ my %context =
Branch: 3 branches
BranchTrueFalseTotal
$kind eq 'window' ? : 0 0 0
$kind eq 'pane' ? : 0 0 0
$kind eq 'client' ? : 0 0 0
171 $kind eq 'window'
172 ? (
173 session_id => 'session_id',
174 window_index => 'window_index',
175 window_active => 'window_active'
176 )
177 : $kind eq 'pane' ? (
178 session_id => 'session_id',
179 window_id => 'window_id',
180 window_index => 'window_index'
181 )
182 : $kind eq 'client' ? (session_id => 'session_id')
183 : ();
184 0 my @extra = sort keys %context;
185 0 my @all = (@keys, @extra);
186 0 my $format = LibTmux::Codec->format(@tokens, map { $context{$_} } @extra);
187 0 return $self->_cmd_op([@{$commands{$kind}}, '-F', $format])->then(
188 0 ▶ sub ($result) {
Subroutine __ANON__: not called CC=8 SCAR=42.8
189 0 my $rows = LibTmux::Codec->decode($result->stdout, scalar @all);
190 0 my @out;
191 0 for my $values (@$rows) {
192 0 my %row;
193 0 @row{@all} = @$values;
194 0 for my $field (@keys) {
195 $row{$field} = undef
196 0 ▶ if $schema->{$field}{nullable} && $row{$field} eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $schema->{$field}{"nullable"} and $row{$field} eq "" 0 0 0
Condition0%0/3
$schema->{$field}{"nullable"} and $row{$field} eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
$schema->{$field}{"nullable"} and $row{$field} eq ""
$schema->{$field}{"nullable"} $row{$field} eq ""
Truth table0%0/3
A and B
A= $schema->{$field}{"nullable"}B= $row{$field} eq ""
ABresult
0X0
100
111
197 $row{$field} = LibTmux::Schema->normalize(
198 0 $schema->{$field}, $row{$field},
199 "$kind.$field", 'Codec'
200 );
201 }
202 0 for my $field (@extra) {
203 $row{$field} = undef
204 0 ▶ if $kind eq 'client' && $row{$field} eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "client" and $row{$field} eq "" 0 0 0
Condition0%0/3
$kind eq "client" and $row{$field} eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
$kind eq "client" and $row{$field} eq ""
$kind eq "client" $row{$field} eq ""
Truth table0%0/3
A and B
A= $kind eq "client"B= $row{$field} eq ""
ABresult
0X0
100
111
205 }
206 0 push @out, \%row;
207 }
208 0 return \@out;
209 }
210 0 );
211 }
212  
213 2 ▶sub _capture_op ($self) {
Subroutine _capture_op: called CC=1 SCAR=0.7
214 2 my $start = time();
215 return $self->_identity_op->then(
216 2 ▶ sub ($before) {
Subroutine __ANON__: called CC=1 SCAR=0.7
217 2 my @kinds = qw(session window pane client);
218 LibTmux::Operation->sequence(
219 8 [map { $self->_list_op($_, $before->{version}) } @kinds])
220 ->then(
221 2 ▶ sub ($lists) {
Subroutine __ANON__: called CC=1 SCAR=0.8
222 $self->_identity_op->then(
223 2 ▶ sub ($after) {
Subroutine __ANON__: called CC=18 SCAR=38.6
224 LibTmux::X::AcquisitionRace->throw(message =>
225 'server generation changed during capture')
226 unless $before->{server_id} eq
227 $after->{server_id}
228 && $before->{generation} eq
229 2 ▶ $after->{generation};
Branch: 1 branch
BranchTrueFalseTotal
unless $before->{"server_id"} eq $after->{"server_id"} and $before->{"generation"} eq $after->{"generation"} 0 2 2
Condition33%1/3
$before->{"server_id"} eq $after->{"server_id"} and $before->{"generation"} eq $after->{"generation"}
!ll&&!rl&&r
002
MC/DC0%0/2
$before->{"server_id"} eq $after->{"server_id"} and $before->{"generation"} eq $after->{"generation"}
$before->{"server_id"} eq $after->{"server_id"} $before->{"generation"} eq $after->{"generation"}
Truth table33%1/3
A and B
A= $before->{"server_id"} eq $after->{"server_id"}B= $before->{"generation"} eq $after->{"generation"}
ABresult
0X0
100
111
230 2 my %lists;
231 2 @lists{@kinds} = @$lists;
232 2 my (@windows, @panes, @links);
233 2 my (%window_seen, %pane_seen, %link_seen);
234 2 my $json = JSON::PP->new->canonical;
235 2 for my $row ($lists{window}->@*) {
236 1 my %record = %$row;
237 1 my $session_id = delete $record{session_id};
238 1 my $index = delete $record{window_index};
239 1 my $active = delete $record{window_active};
240 1 my $fingerprint = $json->encode(\%record);
241 1 ▶ if (exists $window_seen{$record{id}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $window_seen{$record{'id'}}) { } 0 1 1
242 LibTmux::X::AcquisitionRace->throw(
243 message =>
244 'window changed between contextual rows'
245 )
246 unless $window_seen{$record{id}} eq
247 0 ▶ $fingerprint;
Branch: 1 branch
BranchTrueFalseTotal
unless $window_seen{$record{"id"}} eq $fingerprint 0 0 0
248 }
249 else {
250 1 $window_seen{$record{id}} = $fingerprint;
251 1 push @windows, \%record;
252 }
253 1 my $link_id = "$session_id:$index";
254 LibTmux::X::AcquisitionRace->throw(message =>
255 'duplicate session/index association')
256 1 ▶ if $link_seen{$link_id}++;
Branch: 1 branch
BranchTrueFalseTotal
if $link_seen{$link_id}++ 0 1 1
257 push @links,
258 {
259 id => $link_id,
260 session_id => $session_id,
261 window_id => $record{id},
262 1 ▶ index => 0 + $index,
Branch: 1 branch
BranchTrueFalseTotal
$active eq '1' ? : 1 0 1
263 active => $active eq '1' ? true : false
264 };
265 }
266 2 for my $row ($lists{pane}->@*) {
267 0 my %record = %$row;
268 my $context = $row->{session_id} . ':'
269 0 . $row->{window_index};
270 LibTmux::X::AcquisitionRace->throw(message =>
271 'pane context was not captured as a window link'
272 0 ▶ ) unless $link_seen{$context};
Branch: 1 branch
BranchTrueFalseTotal
unless $link_seen{$context} 0 0 0
273 0 delete @record{qw(session_id window_index)};
274 0 my $fingerprint = $json->encode(\%record);
275 0 ▶ if (exists $pane_seen{$record{id}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $pane_seen{$record{'id'}}) { } 0 0 0
276 LibTmux::X::AcquisitionRace->throw(
277 message =>
278 'pane changed between contextual rows'
279 )
280 unless $pane_seen{$record{id}} eq
281 0 ▶ $fingerprint;
Branch: 1 branch
BranchTrueFalseTotal
unless $pane_seen{$record{"id"}} eq $fingerprint 0 0 0
282 }
283 else {
284 0 $pane_seen{$record{id}} = $fingerprint;
285 0 push @panes, \%record;
286 }
287 }
288 2 for my $session ($lists{session}->@*) {
289 my @members =
290 2 grep { $_->{session_id} eq $session->{id} }
291 @links;
292 LibTmux::X::AcquisitionRace->throw(message =>
293 'captured session has incomplete window links'
294 )
295 unless @members
296 2 ▶ && 1 == grep { $_->{active} } @members;
Branch: 1 branch
BranchTrueFalseTotal
unless @members and 1 == grep({$_->{"active"};} @members) 1 1 2
Condition66%2/3
@members and 1 == grep({$_->{"active"};} @members)
!ll&&!rl&&r
101
MC/DC50%1/2
@members and 1 == grep({$_->{"active"};} @members)
@members 1 == grep({$_->{"active"};} @members)
Truth table66%2/3
A and B
A= @membersB= 1 == grep({$_->{"active"};} @members)
ABresult
0X0
100
111
297 }
298 1 for my $window (@windows) {
299 my @members =
300 0 grep { $_->{window_id} eq $window->{id} }
301 @panes;
302 LibTmux::X::AcquisitionRace->throw(message =>
303 'captured window has incomplete panes')
304 unless @members
305 0 ▶ && 1 == grep { $_->{active} } @members;
Branch: 1 branch
BranchTrueFalseTotal
unless @members and 1 == grep({$_->{"active"};} @members) 1 0 1
Condition33%1/3
@members and 1 == grep({$_->{"active"};} @members)
!ll&&!rl&&r
100
MC/DC0%0/2
@members and 1 == grep({$_->{"active"};} @members)
@members 1 == grep({$_->{"active"};} @members)
Truth table33%1/3
A and B
A= @membersB= 1 == grep({$_->{"active"};} @members)
ABresult
0X0
100
111
306 }
307 return LibTmux::Snapshot->from_records(
308 server_id => $before->{server_id},
309 generation => $before->{generation},
310 complete => true,
311 sessions => $lists{session},
312 windows => \@windows,
313 window_links => \@links,
314 panes => \@panes,
315 clients => $lists{client},
316 metadata => {
317 capture_start => $start,
318 capture_end => time(),
319 version => $before->{version},
320 pid => $before->{pid}
321 }
322 0 );
323 }
324 2 );
325 }
326 2 );
327 }
328 2 );
329 }
330 0 ▶sub _literal_format ($value) { $value =~ s/#/##/g; $value }
Subroutine _literal_format: not called CC=1 SCAR=6.9
331  
332 1 ▶sub _target_op ($self, $kind, $target) {
Subroutine _target_op: called CC=12 SCAR=40.9
333 1 ▶ my $handle =
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($target) && $target->isa('LibTmux::Entity') ? : 0 1 1
Condition33%1/3
builtin::blessed($target) and $target->isa("LibTmux::Entity")
!ll&&!rl&&r
100
MC/DC0%0/2
builtin::blessed($target) and $target->isa("LibTmux::Entity")
builtin::blessed($target) $target->isa("LibTmux::Entity")
Truth table33%1/3
A and B
A= builtin::blessed($target)B= $target->isa("LibTmux::Entity")
ABresult
0X0
100
111
334 blessed($target) && $target->isa('LibTmux::Entity') ? $target : undef;
335 1 ▶ LibTmux::X::InvalidArgument->throw(message => "expected $kind handle")
Branch: 1 branch
BranchTrueFalseTotal
if $handle and $handle->kind ne $kind 0 1 1
Condition33%1/3
$handle and $handle->kind ne $kind
!ll&&!rl&&r
100
MC/DC0%0/2
$handle and $handle->kind ne $kind
$handle $handle->kind ne $kind
Truth table33%1/3
A and B
A= $handleB= $handle->kind ne $kind
ABresult
0X0
100
111
336 if $handle && $handle->kind ne $kind;
337 1 ▶ my $id = $handle ? $handle->id : $target;
Branch: 1 branch
BranchTrueFalseTotal
$handle ? : 0 1 1
338 1 ▶ LibTmux::X::InvalidArgument->throw(message => "invalid $kind target")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id and not ref $id and length $id and not $id =~ /\0/u 0 1 1
Condition33%3/9
defined $id and not ref $id and length $id and not $id =~ /\0/u
!ll&&!rl&&r
001
defined $id and not ref $id and length $id
!ll&&!rl&&r
001
defined $id and not ref $id
!ll&&!rl&&r
001
MC/DC0%0/4
defined $id and not ref $id and length $id and not $id =~ /\0/u
defined $id not ref $id length $id not $id =~ /\0/u
Truth table20%1/5
A and not(B) and C and not(D)
A= defined $idB= not ref $idC= length $idD= not $id =~ /\0/u
ABCDresult
0XXX0
10XX0
110X0
11100
11111
339 unless defined($id) && !ref($id) && length($id) && $id !~ /\0/;
340 1 my %pattern = (
341 session => qr/\A\$[0-9]+\z/,
342 window => qr/\A\@[0-9]+\z/,
343 pane => qr/\A%[0-9]+\z/,
344 window_link => qr/\A\$[0-9]+:[0-9]+\z/
345 );
346 LibTmux::X::InvalidArgument->throw(message => "invalid $kind target")
347 1 ▶ if $pattern{$kind} && $id !~ $pattern{$kind};
Branch: 1 branch
BranchTrueFalseTotal
if $pattern{$kind} and not $id =~ /$pattern{$kind}/u 0 1 1
Condition33%1/3
$pattern{$kind} and not $id =~ /$pattern{$kind}/u
!ll&&!rl&&r
010
MC/DC0%0/2
$pattern{$kind} and not $id =~ /$pattern{$kind}/u
$pattern{$kind} not $id =~ /$pattern{$kind}/u
Truth table33%1/3
A and not(B)
A= $pattern{$kind}B= not $id =~ /$pattern{$kind}/u
ABresult
0X0
100
111
348 return $self->_identity_op->then(
349 1 ▶ sub ($identity) {
Subroutine __ANON__: called CC=7 SCAR=37.8
350 1 ▶ if ($handle) {
Branch: 1 branch
BranchTrueFalseTotal
if ($handle) 0 1 1
351 LibTmux::X::StaleReference->throw(
352 message => 'handle belongs to another server generation')
353 unless $handle->server_id eq $identity->{server_id}
354 0 ▶ && $handle->generation eq $identity->{generation};
Branch: 1 branch
BranchTrueFalseTotal
unless $handle->server_id eq $identity->{"server_id"} and $handle->generation eq $identity->{"generation"} 0 0 0
Condition0%0/3
$handle->server_id eq $identity->{"server_id"} and $handle->generation eq $identity->{"generation"}
!ll&&!rl&&r
000
MC/DC0%0/2
$handle->server_id eq $identity->{"server_id"} and $handle->generation eq $identity->{"generation"}
$handle->server_id eq $identity->{"server_id"} $handle->generation eq $identity->{"generation"}
Truth table0%0/3
A and B
A= $handle->server_id eq $identity->{"server_id"}B= $handle->generation eq $identity->{"generation"}
ABresult
0X0
100
111
355 0 ▶ if ($kind eq 'window_link' || $kind eq 'client') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "window_link" or $kind eq "client") 0 0 0
Condition0%0/3
$kind eq "window_link" or $kind eq "client"
l!l&&r!l&&!r
000
MC/DC0%0/2
$kind eq "window_link" or $kind eq "client"
$kind eq "window_link" $kind eq "client"
Truth table0%0/3
A or B
A= $kind eq "window_link"B= $kind eq "client"
ABresult
1X1
011
000
356 0 ▶ my ($flag, $token, $expected) =
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'window_link' ? : 0 0 0
357 $kind eq 'window_link'
358 ? ('-t', 'window_id', $handle->window->id)
359 : ('-c', 'client_pid', $handle->pid);
360 return $self->_cmd_op(
361 ['display-message', '-p', $flag, $id, "#{$token}"])
362 ->then(
363 0 ▶ sub ($result) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
364 0 my $actual = $result->stdout;
365 0 $actual =~ s/\n\z//;
366 0 ▶ LibTmux::X::StaleReference->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless $actual eq $expected 0 0 0
367 message => 'contextual target was replaced')
368 unless $actual eq $expected;
369 0 return [$id, $identity];
370 }
371 )->catch(
372 0 ▶ sub ($error) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
373 0 ▶ die $error
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($error) and $error->isa("LibTmux::X::StaleReference") 0 0 0
Condition0%0/3
builtin::blessed($error) and $error->isa("LibTmux::X::StaleReference")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($error) and $error->isa("LibTmux::X::StaleReference")
builtin::blessed($error) $error->isa("LibTmux::X::StaleReference")
Truth table0%0/3
A and B
A= builtin::blessed($error)B= $error->isa("LibTmux::X::StaleReference")
ABresult
0X0
100
111
374 if blessed($error)
375 && $error->isa('LibTmux::X::StaleReference');
376 0 LibTmux::X::StaleReference->throw(
377 message => 'contextual target no longer exists',
378 cause => $error
379 );
380 }
381 0 );
382 }
383 }
384 1 return [$id, $identity];
385 }
386 1 );
387 }
388  
389 1 ▶sub _pane_command ($args) {
Subroutine _pane_command: called CC=15 SCAR=52.8
390 LibTmux::X::InvalidArgument->throw(
391 message => 'command and shell_command are exclusive')
392 1 ▶ if exists($args->{command}) && exists($args->{shell_command});
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"command"} and exists $args->{"shell_command"} 1 0 1
Condition33%1/3
exists $args->{"command"} and exists $args->{"shell_command"}
!ll&&!rl&&r
001
MC/DC0%0/2
exists $args->{"command"} and exists $args->{"shell_command"}
exists $args->{"command"} exists $args->{"shell_command"}
Truth table33%1/3
A and B
A= exists $args->{"command"}B= exists $args->{"shell_command"}
ABresult
0X0
100
111
393 0 ▶ if (exists $args->{shell_command}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"shell_command"}) 0 0 0
394 LibTmux::X::InvalidArgument->throw(
395 message => 'shell_command must be a NUL-free string')
396 if !defined($args->{shell_command})
397 || ref($args->{shell_command})
398 0 ▶ || $args->{shell_command} =~ /\0/;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $args->{"shell_command"} or ref $args->{"shell_command"} or $args->{"shell_command"} =~ /\0/u 0 0 0
Condition0%0/6
not defined $args->{"shell_command"} or ref $args->{"shell_command"} or $args->{"shell_command"} =~ /\0/u
l!l&&r!l&&!r
000
not defined $args->{"shell_command"} or ref $args->{"shell_command"}
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $args->{"shell_command"} or ref $args->{"shell_command"} or $args->{"shell_command"} =~ /\0/u
not defined $args->{"shell_command"} ref $args->{"shell_command"} $args->{"shell_command"} =~ /\0/u
Truth table0%0/4
not(A) or B or C
A= not defined $args->{"shell_command"}B= ref $args->{"shell_command"}C= $args->{"shell_command"} =~ /\0/u
ABCresult
1XX1
01X1
0011
0000
399 0 return ($args->{shell_command});
400 }
401 0 ▶ return () unless exists $args->{command};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args->{"command"} 0 0 0
402 0 my $argv = $args->{command};
403 0 ▶ LibTmux::X::InvalidArgument->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $argv eq "ARRAY" and @$argv 0 0 0
Condition0%0/3
ref $argv eq "ARRAY" and @$argv
!ll&&!rl&&r
000
MC/DC0%0/2
ref $argv eq "ARRAY" and @$argv
ref $argv eq "ARRAY" @$argv
Truth table0%0/3
A and B
A= ref $argv eq "ARRAY"B= @$argv
ABresult
0X0
100
111
404 message => 'command must be a nonempty literal argument array')
405 unless ref($argv) eq 'ARRAY' && @$argv;
406 0 for (@$argv) {
407 0 ▶ LibTmux::X::InvalidArgument->throw(
Branch: 1 branch
BranchTrueFalseTotal
if not defined $_ or ref $_ or /\0/u 0 0 0
Condition0%0/6
not defined $_ or ref $_ or /\0/u
l!l&&r!l&&!r
000
not defined $_ or ref $_
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $_ or ref $_ or /\0/u
not defined $_ ref $_ /\0/u
Truth table0%0/4
not(A) or B or C
A= not defined $_B= ref $_C= /\0/u
ABCresult
1XX1
01X1
0011
0000
408 message => 'command arguments must be NUL-free scalars')
409 if !defined($_) || ref($_) || /\0/;
410 }
411 0 ▶ return ($^X, '-e', 'exec {$ARGV[0]} @ARGV or exit 127', '--', $argv->[0])
Branch: 1 branch
BranchTrueFalseTotal
if @$argv == 1 0 0 0
412 if @$argv == 1;
413 0 return @$argv;
414 }
415  
416 0 ▶sub _creation_format ($kind) {
Subroutine _creation_format: not called CC=1 SCAR=6.9
417 0 LibTmux::Codec->format(qw(socket_path pid start_time version),
418 $kind . '_id');
419 }
420  
421 0 ▶sub _created_op ($self, $argv, $kind) {
Subroutine _created_op: not called CC=1 SCAR=6.9
422 return $self->_cmd_op($argv)->then(
423 0 ▶ sub ($result) {
Subroutine __ANON__: not called CC=7 SCAR=40.3
424 0 my $receipt;
425 my $capture;
426 0 try {
427 0 my $rows = LibTmux::Codec->decode($result->stdout, 5);
428 0 ▶ LibTmux::X::Codec->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless @$rows == 1 0 0 0
429 message => 'expected one creation receipt')
430 unless @$rows == 1;
431 0 my ($server_id, $pid, $started, $version, $id) = $rows->[0]->@*;
432 0 ▶ LibTmux::X::Codec->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless length $server_id and $pid =~ /\A[1-9][0-9]*\z/u and $started =~ /\A[0-9]+\z/u 0 0 0
Condition0%0/6
length $server_id and $pid =~ /\A[1-9][0-9]*\z/u and $started =~ /\A[0-9]+\z/u
!ll&&!rl&&r
000
length $server_id and $pid =~ /\A[1-9][0-9]*\z/u
!ll&&!rl&&r
000
MC/DC0%0/3
length $server_id and $pid =~ /\A[1-9][0-9]*\z/u and $started =~ /\A[0-9]+\z/u
length $server_id $pid =~ /\A[1-9][0-9]*\z/u $started =~ /\A[0-9]+\z/u
Truth table0%0/4
A and B and C
A= length $server_idB= $pid =~ /\A[1-9][0-9]*\z/uC= $started =~ /\A[0-9]+\z/u
ABCresult
0XX0
10X0
1100
1111
433 message => 'invalid creation generation')
434 unless length($server_id)
435 && $pid =~ /\A[1-9][0-9]*\z/
436 && $started =~ /\A[0-9]+\z/;
437 0 my %plural = (
438 session => 'sessions',
439 window => 'windows',
440 pane => 'panes'
441 );
442 my $store = LibTmux::Snapshot->from_records(
443 server_id => $server_id,
444 generation => "$pid/$started",
445 complete => false,
446 0 $plural{$kind} => [{id => $id}]
447 );
448 0 ▶ $receipt =
Branch: 2 branches
BranchTrueFalseTotal
$kind eq 'session' ? : 0 0 0
$kind eq 'window' ? : 0 0 0
449 $kind eq 'session' ? $store->session_by_id($id)
450 : $kind eq 'window' ? $store->window_by_id($id)
451 : $store->pane_by_id($id);
452 0 $capture = $self->_capture_op;
453 }
454 catch ($error) {
455 0 LibTmux::X::Creation->throw(
456 message =>
457 'creation accepted but receipt/acquisition failed',
458 created => $receipt,
459 cause => $error,
460 result => $result,
461 dispatched => true
462 );
463 }
464 return $capture->then(
465 0 ▶ sub ($snapshot) {
Subroutine __ANON__: not called CC=6 SCAR=37.4
466 0 ▶ LibTmux::X::AcquisitionRace->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless $snapshot->server_id eq $receipt->server_id and $snapshot->generation eq $receipt->generation 0 0 0
Condition0%0/3
$snapshot->server_id eq $receipt->server_id and $snapshot->generation eq $receipt->generation
!ll&&!rl&&r
000
MC/DC0%0/2
$snapshot->server_id eq $receipt->server_id and $snapshot->generation eq $receipt->generation
$snapshot->server_id eq $receipt->server_id $snapshot->generation eq $receipt->generation
Truth table0%0/3
A and B
A= $snapshot->server_id eq $receipt->server_idB= $snapshot->generation eq $receipt->generation
ABresult
0X0
100
111
467 message => 'server changed after creation')
468 unless $snapshot->server_id eq $receipt->server_id
469 && $snapshot->generation eq $receipt->generation;
470 0 my $id = $receipt->id;
471 0 ▶ my $entity =
Branch: 2 branches
BranchTrueFalseTotal
$kind eq 'session' ? : 0 0 0
$kind eq 'window' ? : 0 0 0
472 $kind eq 'session' ? $snapshot->session_by_id($id)
473 : $kind eq 'window' ? $snapshot->window_by_id($id)
474 : $snapshot->pane_by_id($id);
475 0 ▶ LibTmux::X::AcquisitionRace->throw(message =>
Branch: 1 branch
BranchTrueFalseTotal
unless $entity 0 0 0
476 'created entity disappeared before acquisition')
477 unless $entity;
478 0 return $entity;
479 }
480 )->catch(
481 0 ▶ sub ($error) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
482 0 LibTmux::X::Creation->throw(
483 message => 'creation accepted but acquisition failed',
484 created => $receipt,
485 cause => $error,
486 result => $result,
487 dispatched => true
488 );
489 }
490 0 );
491 }
492 0 );
493 }
494  
495 22 ▶sub _prepare ($self, $name, %args) {
Subroutine _prepare: called CC=62 SCAR=71.4
496 22 ▶ if ($name eq 'select_layout') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "select_layout") 1 21 22
497 1 my $layout = $args{layout};
498 1 my @matches = grep { index($_, $layout) == 0 }
499 qw(even-horizontal even-vertical main-horizontal main-vertical tiled);
500 1 ▶ LibTmux::X::InvalidArgument->throw(message =>
Branch: 1 branch
BranchTrueFalseTotal
unless @matches == 1 or $layout =~ /\A[0-9a-fA-F]{4},/u 1 0 1
Condition33%1/3
@matches == 1 or $layout =~ /\A[0-9a-fA-F]{4},/u
l!l&&r!l&&!r
001
MC/DC0%0/2
@matches == 1 or $layout =~ /\A[0-9a-fA-F]{4},/u
@matches == 1 $layout =~ /\A[0-9a-fA-F]{4},/u
Truth table33%1/3
A or B
A= @matches == 1B= $layout =~ /\A[0-9a-fA-F]{4},/u
ABresult
1X1
011
000
501 'layout must be an unambiguous predefined name or a checksum-prefixed tmux layout'
502 ) unless @matches == 1 || $layout =~ /\A[0-9a-fA-F]{4},/;
503 }
504 21 ▶ if ($name eq 'snapshot') { return $self->_capture_op }
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "snapshot") 2 19 21
505 19 ▶ if ($name eq 'execute') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "execute") 0 19 19
506 0 return $self->_raw_op(delete($args{argv}), %args);
507 }
508 0 ▶ if ($name eq 'cmd') { return $self->_cmd_op($args{argv}) }
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "cmd") 0 19 19
509 19 ▶ if ($name eq 'clients') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "clients") 0 19 19
510 0 ▶ return $self->_capture_op->then(sub ($s) { $s->clients });
Subroutine __ANON__: not called CC=1 SCAR=6.9
511 }
512 19 ▶ if ($name eq 'listings') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "listings") 0 19 19
513 return $self->_identity_op->then(
514 0 ▶ sub ($identity) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
515 0 $self->_list_op($args{kind}, $identity->{version});
516 }
517 0 );
518 }
519 19 ▶ if ($name eq 'new_session') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "new_session") 0 19 19
520 LibTmux::X::InvalidArgument->throw(
521 message => 'session name is required')
522 0 ▶ unless defined($args{name}) && !ref($args{name});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"name"} and not ref $args{"name"} 0 0 0
Condition0%0/3
defined $args{"name"} and not ref $args{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"name"} and not ref $args{"name"}
defined $args{"name"} not ref $args{"name"}
Truth table0%0/3
A and not(B)
A= defined $args{"name"}B= not ref $args{"name"}
ABresult
0X0
100
111
523 my @argv = (
524 'new-session', '-d', '-P', '-F', _creation_format('session'),
525 '-s', _literal_format($args{name})
526 0 );
527 0 ▶ push @argv, ('-x', $args{width}) if exists $args{width};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"width"} 0 0 0
528 0 ▶ push @argv, ('-y', $args{height}) if exists $args{height};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"height"} 0 0 0
529 0 ▶ push @argv, ('-c', _literal_format($args{cwd})) if exists $args{cwd};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"cwd"} 0 0 0
530 0 push @argv, map { ('-e', $_ . '=' . $args{environment}{$_}) }
531 0 ▶ sort keys %{$args{environment} // {}};
Condition0%0/2
$args{"environment"} // {}
l!l
00
MC/DC0%0/1
$args{"environment"} // {}
$args{"environment"}
Truth table0%0/2
A
A= $args{"environment"}
Aresult
11
00
532 0 push @argv, '--', _pane_command(\%args);
533 return $self->_identity_op->catch(
534 0 ▶ sub ($error) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
535 0 ▶ die $error
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($error) and $error->isa("LibTmux::X::NoServer") 0 0 0
Condition0%0/3
builtin::blessed($error) and $error->isa("LibTmux::X::NoServer")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($error) and $error->isa("LibTmux::X::NoServer")
builtin::blessed($error) $error->isa("LibTmux::X::NoServer")
Truth table0%0/3
A and B
A= builtin::blessed($error)B= $error->isa("LibTmux::X::NoServer")
ABresult
0X0
100
111
536 unless blessed($error)
537 && $error->isa('LibTmux::X::NoServer');
538 0 undef;
539 }
540 0 ▶ )->then(sub { $self->_created_op(\@argv, 'session') });
Subroutine __ANON__: not called CC=1 SCAR=6.9
541 }
542 19 ▶ if ($name eq 'new_window' || $name eq 'split_pane') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "new_window" or $name eq "split_pane") 1 18 19
Condition66%2/3
$name eq "new_window" or $name eq "split_pane"
l!l&&r!l&&!r
0118
MC/DC50%1/2
$name eq "new_window" or $name eq "split_pane"
$name eq "new_window" $name eq "split_pane"
Truth table66%2/3
A or B
A= $name eq "new_window"B= $name eq "split_pane"
ABresult
1X1
011
000
543 1 my $split = $name eq 'split_pane';
544 1 my @command = _pane_command(\%args);
545 return $self->_target_op($split ? 'pane' : 'session',
546 $args{$split ? 'pane' : 'session'})->then(
547 0 ▶ sub ($target) {
Subroutine __ANON__: not called CC=11 SCAR=48.8
548 0 ▶ my @argv = (
Branch: 3 branches
BranchTrueFalseTotal
$split ? : 0 0 0
$split ? : 0 0 0
$split ? : 0 0 0
549 $split ? 'split-window' : 'new-window',
550 '-d',
551 '-P',
552 '-F',
553 $split
554 ? _creation_format('pane')
555 : _creation_format('window'),
556 '-t',
557 $split ? $target->[0] : $target->[0] . ':'
558 );
559 0 ▶ push @argv, '-h' if $split && $args{horizontal};
Branch: 1 branch
BranchTrueFalseTotal
if $split and $args{"horizontal"} 0 0 0
Condition0%0/3
$split and $args{"horizontal"}
!ll&&!rl&&r
000
MC/DC0%0/2
$split and $args{"horizontal"}
$split $args{"horizontal"}
Truth table0%0/3
A and B
A= $splitB= $args{"horizontal"}
ABresult
0X0
100
111
560 0 ▶ if (!$split && exists $args{name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $split and exists $args{"name"}) 0 0 0
Condition0%0/3
not $split and exists $args{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $split and exists $args{"name"}
not $split exists $args{"name"}
Truth table0%0/3
not(A) and B
A= not $splitB= exists $args{"name"}
ABresult
0X0
100
111
561 0 push @argv, ('-n', _literal_format($args{name}));
562 }
563 push @argv, ('-c', _literal_format($args{cwd}))
564 0 ▶ if exists $args{cwd};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"cwd"} 0 0 0
565 0 push @argv, map { ('-e', $_ . '=' . $args{environment}{$_}) }
566 0 ▶ sort keys %{$args{environment} // {}};
Condition0%0/2
$args{"environment"} // {}
l!l
00
MC/DC0%0/1
$args{"environment"} // {}
$args{"environment"}
Truth table0%0/2
A
A= $args{"environment"}
Aresult
11
00
567 0 push @argv, '--', @command;
568 0 ▶ return $self->_created_op(\@argv, $split ? 'pane' : 'window');
Branch: 1 branch
BranchTrueFalseTotal
$split ? : 0 0 0
569 }
570 0 ▶ );
Branch: 2 branches
BranchTrueFalseTotal
$split ? : 0 0 0
$split ? : 0 0 0
571 }
572 18 ▶ if ($name eq 'link_window') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "link_window") 0 18 18
573 return $self->_target_op('window', $args{window})->then(
574 0 ▶ sub ($window) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
575 $self->_target_op('session', $args{session})->then(
576 0 ▶ sub ($session) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
577 $self->_cmd_op(
578 [
579 'link-window', '-s', $window->[0], '-t',
580 $session->[0] . ':' . ($args{index} // '')
581 ]
582 0 ▶ )->then(sub { undef });
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/2
$args{"index"} // ""
l!l
00
MC/DC0%0/1
$args{"index"} // ""
$args{"index"}
Truth table0%0/2
A
A= $args{"index"}
Aresult
11
00
583 }
584 0 );
585 }
586 0 );
587 }
588 18 ▶ if ($name eq 'move_window') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "move_window") 0 18 18
589 return $self->_target_op('window_link', $args{link})->then(
590 0 ▶ sub ($link) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
591 $self->_target_op('session', $args{session})->then(
592 0 ▶ sub ($session) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
593 $self->_cmd_op(
594 [
595 'move-window', '-s', $link->[0], '-t',
596 $session->[0] . ':' . ($args{index} // '')
597 ]
598 0 ▶ )->then(sub { undef });
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/2
$args{"index"} // ""
l!l
00
MC/DC0%0/1
$args{"index"} // ""
$args{"index"}
Truth table0%0/2
A
A= $args{"index"}
Aresult
11
00
599 }
600 0 );
601 }
602 0 );
603 }
604 18 my %simple = (
605 rename_session =>
606 ['session', 'session', 'rename-session', 'name', 'format'],
607 rename_window =>
608 ['window', 'window', 'rename-window', 'name', 'format'],
609 unlink_window => ['window_link', 'link', 'unlink-window'],
610 select_window => ['window_link', 'link', 'select-window'],
611 select_pane => ['pane', 'pane', 'select-pane'],
612 select_layout => ['window', 'window', 'select-layout', 'layout'],
613 kill_pane => ['pane', 'pane', 'kill-pane'],
614 kill_window => ['window', 'window', 'kill-window'],
615 kill_session => ['session', 'session', 'kill-session'],
616 detach_client => ['client', 'client', 'detach-client'],
617 );
618 18 ▶ if (my $spec = $simple{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $spec = $simple{$name}) 0 18 18
619 return $self->_target_op($spec->[0], $args{$spec->[1]})->then(
620 0 ▶ sub ($target) {
Subroutine __ANON__: not called CC=4 SCAR=30.0
621 0 my @argv = ($spec->[2], '-t', $target->[0]);
622 0 ▶ if ($spec->[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec->[3]) 0 0 0
623 LibTmux::X::InvalidArgument->throw(
624 message => "$spec->[3] is required")
625 0 ▶ unless defined $args{$spec->[3]};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{$spec->[3]} 0 0 0
626 push @argv, '--',
627 $spec->[4]
628 ? _literal_format($args{$spec->[3]})
629 0 ▶ : $args{$spec->[3]};
Branch: 1 branch
BranchTrueFalseTotal
$spec->[4] ? : 0 0 0
630 }
631 0 ▶ return $self->_cmd_op(\@argv)->then(sub { undef });
Subroutine __ANON__: not called CC=1 SCAR=6.9
632 }
633 0 );
634 }
635 18 ▶ if ($name eq 'kill_server') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "kill_server") 0 18 18
636 0 ▶ return $self->_cmd_op(['kill-server'])->then(sub { undef });
Subroutine __ANON__: not called CC=1 SCAR=6.9
637 }
638 18 ▶ if ( $name eq 'resize_pane'
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "resize_pane" or $name eq "set_title" or $name eq "send_keys" or $name eq "send_text" or $name eq "capture_pane") 1 17 18
Condition58%7/12
$name eq "resize_pane" or $name eq "set_title" or $name eq "send_keys" or $name eq "send_text" or $name eq "capture_pane"
l!l&&r!l&&!r
1017
$name eq "resize_pane" or $name eq "set_title" or $name eq "send_keys" or $name eq "send_text"
l!l&&r!l&&!r
1017
$name eq "resize_pane" or $name eq "set_title" or $name eq "send_keys"
l!l&&r!l&&!r
0117
$name eq "resize_pane" or $name eq "set_title"
l!l&&r!l&&!r
0018
MC/DC20%1/5
$name eq "resize_pane" or $name eq "set_title" or $name eq "send_keys" or $name eq "send_text" or $name eq "capture_pane"
$name eq "resize_pane" $name eq "set_title" $name eq "send_keys" $name eq "send_text" $name eq "capture_pane"
Truth table33%2/6
A or B or C or D or E
A= $name eq "resize_pane"B= $name eq "set_title"C= $name eq "send_keys"D= $name eq "send_text"E= $name eq "capture_pane"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
639 || $name eq 'set_title'
640 || $name eq 'send_keys'
641 || $name eq 'send_text'
642 || $name eq 'capture_pane')
643 {
644 return $self->_target_op('pane', $args{pane})->then(
645 1 ▶ sub ($target) {
Subroutine __ANON__: called CC=10 SCAR=36.0
646 1 my @argv;
647 1 ▶ if ($name eq 'resize_pane') {
Branch: 4 branches
BranchTrueFalseTotal
if ($name eq 'resize_pane') { } 0 1 1
elsif ($name eq 'set_title') { } 0 1 1
elsif ($name eq 'send_keys') { } 1 0 1
elsif ($name eq 'send_text') { } 0 0 0
648 0 @argv = ('resize-pane', '-t', $target->[0]);
649 0 ▶ push @argv, ('-x', $args{width}) if exists $args{width};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"width"} 0 0 0
650 0 ▶ push @argv, ('-y', $args{height}) if exists $args{height};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"height"} 0 0 0
651 }
652 elsif ($name eq 'set_title') {
653 @argv = (
654 'select-pane', '-t', $target->[0], '-T',
655 _literal_format($args{title})
656 0 );
657 }
658 elsif ($name eq 'send_keys') {
659 LibTmux::X::InvalidArgument->throw(
660 message => 'keys must be an array reference')
661 1 ▶ unless ref($args{keys}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"keys"} eq "ARRAY" 0 1 1
662 @argv = (
663 'send-keys', '-t', $target->[0], '--',
664 $args{keys}->@*
665 1 );
666 }
667 elsif ($name eq 'send_text') {
668 @argv = (
669 'send-keys', '-t', $target->[0], '-l', '--', $args{text}
670 0 );
671 }
672 else {
673 0 @argv = ('capture-pane', '-p', '-t', $target->[0]);
674 0 ▶ push @argv, ('-S', $args{start}) if exists $args{start};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"start"} 0 0 0
675 0 ▶ push @argv, ('-E', $args{end}) if exists $args{end};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"end"} 0 0 0
676 }
677 return $self->_cmd_op(\@argv)->then(
678 1 ▶ sub ($result) {
Subroutine __ANON__: called CC=4 SCAR=17.1
679 1 ▶ return $result->stdout if $name eq 'capture_pane';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "capture_pane" 0 1 1
680 return $self->_cmd_op(
681 ['send-keys', '-t', $target->[0], 'Enter'])
682 0 ▶ ->then(sub { undef })
Subroutine __ANON__: not called CC=1 SCAR=6.9
683 1 ▶ if $name eq 'send_text' && $args{enter};
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "send_text" and $args{"enter"} 0 1 1
Condition33%1/3
$name eq "send_text" and $args{"enter"}
!ll&&!rl&&r
100
MC/DC0%0/2
$name eq "send_text" and $args{"enter"}
$name eq "send_text" $args{"enter"}
Truth table33%1/3
A and B
A= $name eq "send_text"B= $args{"enter"}
ABresult
0X0
100
111
684 1 return undef;
685 }
686 1 );
687 }
688 1 );
689 }
690 17 ▶ if ( $name eq 'set_option'
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "set_option" or $name eq "get_option" or $name eq "unset_option") 0 17 17
Condition33%2/6
$name eq "set_option" or $name eq "get_option" or $name eq "unset_option"
l!l&&r!l&&!r
0017
$name eq "set_option" or $name eq "get_option"
l!l&&r!l&&!r
0017
MC/DC0%0/3
$name eq "set_option" or $name eq "get_option" or $name eq "unset_option"
$name eq "set_option" $name eq "get_option" $name eq "unset_option"
Truth table25%1/4
A or B or C
A= $name eq "set_option"B= $name eq "get_option"C= $name eq "unset_option"
ABCresult
1XX1
01X1
0011
0000
691 || $name eq 'get_option'
692 || $name eq 'unset_option')
693 {
694 0 my %scope =
695 (session => '', window => '-w', pane => '-p', server => '-s');
696 0 ▶ my $scope = $args{scope} // 'session';
Condition0%0/2
$args{"scope"} // "session"
l!l
00
MC/DC0%0/1
$args{"scope"} // "session"
$args{"scope"}
Truth table0%0/2
A
A= $args{"scope"}
Aresult
11
00
697 LibTmux::X::InvalidArgument->throw(message => 'unknown option scope')
698 0 ▶ unless exists $scope{$scope};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $scope{$scope} 0 0 0
699 0 ▶ my @argv = ($name eq 'get_option' ? 'show-options' : 'set-option');
Branch: 1 branch
BranchTrueFalseTotal
$name eq 'get_option' ? : 0 0 0
700 0 ▶ push @argv, $scope{$scope} if length $scope{$scope};
Branch: 1 branch
BranchTrueFalseTotal
if length $scope{$scope} 0 0 0
701 0 ▶ push @argv, '-g' if $args{global};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"global"} 0 0 0
702 0 ▶ push @argv, ('-t', $args{target}) if exists $args{target};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"target"} 0 0 0
703 0 ▶ push @argv, '-A' if $name eq 'get_option' && $args{inherited};
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "get_option" and $args{"inherited"} 0 0 0
Condition0%0/3
$name eq "get_option" and $args{"inherited"}
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "get_option" and $args{"inherited"}
$name eq "get_option" $args{"inherited"}
Truth table0%0/3
A and B
A= $name eq "get_option"B= $args{"inherited"}
ABresult
0X0
100
111
704 0 ▶ push @argv, '-u' if $name eq 'unset_option';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "unset_option" 0 0 0
705 0 push @argv, '--', $args{name};
706 0 ▶ push @argv, $args{value} if $name eq 'set_option';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "set_option" 0 0 0
707 return $self->_cmd_op(\@argv)->then(
708 0 ▶ sub ($result) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
709 0 ▶ return undef unless $name eq 'get_option';
Branch: 1 branch
BranchTrueFalseTotal
unless $name eq "get_option" 0 0 0
710 return LibTmux::Codec->_option_value($result->stdout,
711 0 $args{name});
712 }
713 0 );
714 }
715 17 ▶ if ($name eq 'set_hook' || $name eq 'show_hooks') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "set_hook" or $name eq "show_hooks") 0 17 17
Condition33%1/3
$name eq "set_hook" or $name eq "show_hooks"
l!l&&r!l&&!r
0017
MC/DC0%0/2
$name eq "set_hook" or $name eq "show_hooks"
$name eq "set_hook" $name eq "show_hooks"
Truth table33%1/3
A or B
A= $name eq "set_hook"B= $name eq "show_hooks"
ABresult
1X1
011
000
716 0 ▶ my @argv = ($name eq 'set_hook' ? 'set-hook' : 'show-hooks');
Branch: 1 branch
BranchTrueFalseTotal
$name eq 'set_hook' ? : 0 0 0
717 0 ▶ push @argv, '-g' if $args{global};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"global"} 0 0 0
718 0 ▶ push @argv, ('-t', $args{target}) if exists $args{target};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"target"} 0 0 0
719 0 ▶ push @argv, ('--', $args{name}, $args{command}) if $name eq 'set_hook';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "set_hook" 0 0 0
720 return $self->_cmd_op(\@argv)
721 0 ▶ ->then(sub ($r) { $name eq 'show_hooks' ? $r->stdout : undef });
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$name eq 'show_hooks' ? : 0 0 0
722 }
723 17 ▶ if ($name =~ /\A(?:set|get|unset)_environment\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /\A(?:set|get|unset)_environment\z/u) 0 17 17
724 LibTmux::X::InvalidArgument->throw(
725 message => 'invalid environment name')
726 unless defined($args{name})
727 0 ▶ && $args{name} =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"name"} and $args{"name"} =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u 0 0 0
Condition0%0/3
defined $args{"name"} and $args{"name"} =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"name"} and $args{"name"} =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u
defined $args{"name"} $args{"name"} =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u
Truth table0%0/3
A and B
A= defined $args{"name"}B= $args{"name"} =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u
ABresult
0X0
100
111
728 my $target =
729 exists($args{session})
730 ? $self->_target_op('session', $args{session})
731 0 ▶ : LibTmux::Operation->value(undef);
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'session'} ? : 0 0 0
732 return $target->then(
733 0 ▶ sub ($resolved) {
Subroutine __ANON__: not called CC=6 SCAR=37.4
734 0 ▶ my @argv = (
Branch: 1 branch
BranchTrueFalseTotal
$name eq 'get_environment' ? : 0 0 0
735 $name eq 'get_environment'
736 ? 'show-environment'
737 : 'set-environment'
738 );
739 0 ▶ push @argv, defined($resolved) ? ('-t', $resolved->[0]) : '-g';
Branch: 1 branch
BranchTrueFalseTotal
defined $resolved ? : 0 0 0
740 0 ▶ push @argv, '-s' if $name eq 'get_environment';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "get_environment" 0 0 0
741 0 ▶ push @argv, '-u' if $name eq 'unset_environment';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "unset_environment" 0 0 0
742 0 push @argv, '--', $args{name};
743 0 ▶ push @argv, $args{value} if $name eq 'set_environment';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "set_environment" 0 0 0
744 return $self->_cmd_op(\@argv)->then(
745 0 ▶ sub ($r) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
746 0 ▶ return undef unless $name eq 'get_environment';
Branch: 1 branch
BranchTrueFalseTotal
unless $name eq "get_environment" 0 0 0
747 my $text =
748 LibTmux::Codec->_environment_value($r->stdout,
749 0 $args{name});
750 0 ▶ LibTmux::X::Command->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text 0 0 0
751 message => 'environment variable is unset',
752 result => $r
753 ) unless defined $text;
754 0 return $text;
755 }
756 0 );
757 }
758 0 );
759 }
760 17 ▶ if ( $name eq 'set_buffer'
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "set_buffer" or $name eq "show_buffer" or $name eq "delete_buffer") 0 17 17
Condition33%2/6
$name eq "set_buffer" or $name eq "show_buffer" or $name eq "delete_buffer"
l!l&&r!l&&!r
0017
$name eq "set_buffer" or $name eq "show_buffer"
l!l&&r!l&&!r
0017
MC/DC0%0/3
$name eq "set_buffer" or $name eq "show_buffer" or $name eq "delete_buffer"
$name eq "set_buffer" $name eq "show_buffer" $name eq "delete_buffer"
Truth table25%1/4
A or B or C
A= $name eq "set_buffer"B= $name eq "show_buffer"C= $name eq "delete_buffer"
ABCresult
1XX1
01X1
0011
0000
761 || $name eq 'show_buffer'
762 || $name eq 'delete_buffer')
763 {
764 my @argv = (
765 $name eq 'set_buffer' ? 'load-buffer'
766 : $name eq 'show_buffer' ? 'show-buffer'
767 : 'delete-buffer',
768 '-b', $args{name}
769 0 ▶ );
Branch: 2 branches
BranchTrueFalseTotal
$name eq 'set_buffer' ? : 0 0 0
$name eq 'show_buffer' ? : 0 0 0
770 0 ▶ push @argv, '-' if $name eq 'set_buffer';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "set_buffer" 0 0 0
771 return $self->_cmd_op(\@argv,
772 $name eq 'set_buffer' ? (stdin => $args{data}) : ())->then(
773 0 ▶ sub ($r) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
774 0 ▶ $name eq 'show_buffer' ? $r->stdout : undef;
Branch: 1 branch
BranchTrueFalseTotal
$name eq 'show_buffer' ? : 0 0 0
775 }
776 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$name eq 'set_buffer' ? : 0 0 0
777 }
778 17 ▶ if ($name eq 'batch') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "batch") 0 17 17
779 LibTmux::X::InvalidArgument->throw(
780 message => 'batch needs an array of argv arrays')
781 0 ▶ unless ref($args{requests}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"requests"} eq "ARRAY" 0 0 0
782 my @ops = map {
783 $self->_raw_op($_)
784 0 ▶ ->then(sub ($r) { +{result => $r, error => undef} })
Subroutine __ANON__: not called CC=1 SCAR=6.9
785 0 ▶ ->catch(sub ($e) { +{result => undef, error => $e} })
Subroutine __ANON__: not called CC=1 SCAR=6.9
786 0 } $args{requests}->@*;
787 0 return LibTmux::Operation->sequence(\@ops);
788 }
789 17 ▶ if ($name eq 'query_panes') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "query_panes") 17 0 17
790 17 require LibTmux::QueryPlan;
791 17 my $observer = delete $args{on_verification};
792 17 my $plan = LibTmux::QueryPlan->new(%args);
793 9 ▶ my $finish = sub ($selection, $report) {
Subroutine __ANON__: called CC=2 SCAR=7.2
794 9 ▶ $observer->($report) if defined $observer;
Branch: 1 branch
BranchTrueFalseTotal
if defined $observer 9 0 9
795 8 return $selection;
796 16 };
797 return $self->_capture_op->then(
798 15 ▶ sub ($snapshot) {
Subroutine __ANON__: called CC=5 SCAR=16.1
799 15 my $local = $snapshot->panes->where($plan->filter);
800 14 ▶ return $finish->(
Branch: 1 branch
BranchTrueFalseTotal
if $plan->policy eq "never" 2 12 14
801 $local, $plan->_verification_report($snapshot, $local, {})
802 ) if $plan->policy eq 'never';
803 12 my $lowered = $plan->lowering($snapshot->metadata->{version});
804 LibTmux::X::Unsupported->throw(message =>
805 'query has no complete exact native implementation')
806 12 ▶ if $plan->policy eq 'require' && !$lowered->{exact};
Branch: 1 branch
BranchTrueFalseTotal
if $plan->policy eq "require" and not $lowered->{"exact"} 1 11 12
Condition100%3/3
$plan->policy eq "require" and not $lowered->{"exact"}
!ll&&!rl&&r
1011
MC/DC100%2/2
$plan->policy eq "require" and not $lowered->{"exact"}
$plan->policy eq "require" not $lowered->{"exact"}
Truth table100%3/3
A and not(B)
A= $plan->policy eq "require"B= not $lowered->{"exact"}
ABresult
0X0
100
111
807 return $finish->(
808 $local,
809 $plan->_verification_report($snapshot, $local, $lowered)
810 11 ▶ ) unless defined $lowered->{filter};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lowered->{"filter"} 1 10 11
811 return $self->_cmd_op(
812 [
813 'list-panes', '-a',
814 '-f', $lowered->{filter},
815 '-F', '#{pane_id}'
816 ]
817 )->then(
818 9 ▶ sub ($r) {
Subroutine __ANON__: called CC=8 SCAR=20.8
819 9 my (%native, @native);
820 9 for my $id (grep { length } split /\n/, $r->stdout) {
821 15 ▶ LibTmux::X::Codec->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless $id =~ /\A%[0-9]+\z/u 1 14 15
822 message => 'invalid native candidate ID')
823 unless $id =~ /\A%[0-9]+\z/;
824 14 ▶ push @native, $id unless $native{$id}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $native{$id}++ 12 2 14
825 }
826 8 my $report =
827 $plan->_verification_report($snapshot, $local,
828 $lowered, \@native);
829 8 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($report->{"status"} eq "disagreed" and $plan->_is_native || $plan->policy eq "require") 2 6 8
Condition100%6/6
$report->{"status"} eq "disagreed" and $plan->_is_native || $plan->policy eq "require"
!ll&&!rl&&r
422
$plan->_is_native or $plan->policy eq "require"
l!l&&r!l&&!r
112
MC/DC100%3/3
$report->{"status"} eq "disagreed" and $plan->_is_native || $plan->policy eq "require"
$report->{"status"} eq "disagreed" $plan->_is_native $plan->policy eq "require"
Truth table100%4/4
A and B or C
A= $report->{"status"} eq "disagreed"B= $plan->_is_nativeC= $plan->policy eq "require"
ABCresult
0XX0
1000
11X1
1011
830 $report->{status} eq 'disagreed'
831 && ($plan->_is_native || $plan->policy eq 'require')
832 )
833 {
834 2 LibTmux::X::QueryMismatch->throw(
835 message =>
836 'native candidates disagree with captured data; cause undetermined',
837 verification => $report
838 );
839 }
840 my $selection =
841 $plan->_is_native
842 ? $snapshot->panes->grep(
843 3 ▶ sub ($pane) { $native{$pane->id} })
Subroutine __ANON__: called CC=1 SCAR=0.0
844 6 ▶ : $local;
Branch: 1 branch
BranchTrueFalseTotal
$plan->_is_native ? : 1 5 6
845 6 return $finish->($selection, $report);
846 }
847 10 );
848 }
849 16 );
850 }
851 0 LibTmux::X::InvalidArgument->throw(message => "unknown operation $name");
852 }
853  
854 28 ▶sub operation ($self, $name, %args) {
Subroutine operation: called CC=7 SCAR=20.6
Pod documented
855 28 $self->_validate_options($name, \%args);
856 23 for my $key (qw(argv keys command)) {
857 69 ▶ $args{$key} = [$args{$key}->@*] if ref($args{$key}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $args{$key} eq "ARRAY" 2 67 69
858 }
859 0 ▶ $args{environment} = {%{$args{environment}}} if exists $args{environment};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"environment"} 0 23 23
860 $args{requests} =
861 0 ▶ [map { ref($_) eq 'ARRAY' ? [@$_] : $_ } $args{requests}->@*]
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 0 0 0
862 23 ▶ if exists $args{requests};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"requests"} 0 23 23
863 23 ▶ if ($name eq 'explain_panes') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "explain_panes") 1 22 23
864 1 require LibTmux::QueryPlan;
865 1 return LibTmux::Operation->value(LibTmux::QueryPlan->new(%args));
866 }
867 22 my $operation = $self->_prepare($name, %args);
868 19 ▶ return $self->_binary_op->then(sub { $operation });
Subroutine __ANON__: called CC=1 SCAR=0.0
869 }
870  
871 28 ▶sub _validate_options ($self, $name, $args) {
Subroutine _validate_options: called CC=53 SCAR=64.1
872 28 my $spec = LibTmux::Schema->catalog->{operations}{$name};
873 28 ▶ LibTmux::X::InvalidArgument->throw(message => "unknown operation $name")
Branch: 1 branch
BranchTrueFalseTotal
unless $spec 0 28 28
874 unless $spec;
875 28 my $params = $spec->{parameters};
876 LibTmux::X::InvalidArgument->throw(message => "unknown $name option $_")
877 28 for sort grep { !exists $params->{$_} } keys %$args;
878 27 for my $key (sort keys %$params) {
879 87 my $param = $params->{$key};
880 LibTmux::X::InvalidArgument->throw(message => "$name requires $key")
881 87 ▶ if $param->{required} && !exists $args->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $param->{"required"} and not exists $args->{$key} 0 87 87
Condition66%2/3
$param->{"required"} and not exists $args->{$key}
!ll&&!rl&&r
8160
MC/DC0%0/2
$param->{"required"} and not exists $args->{$key}
$param->{"required"} not exists $args->{$key}
Truth table66%2/3
A and not(B)
A= $param->{"required"}B= not exists $args->{$key}
ABresult
0X0
100
111
882 87 ▶ next unless exists $args->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args->{$key} 42 45 87
883 45 my $value = $args->{$key};
884 45 my $type = $param->{type};
885 45 my $valid = true;
886 45 ▶ if ($type eq 'text' || $type eq 'bytes') {
Branch: 9 branches
BranchTrueFalseTotal
if ($type eq 'text' or $type eq 'bytes') { } 8 37 45
elsif ($type eq 'integer' or $type eq 'positive' or $type eq 'nonnegative') { } 0 37 37
elsif ($type eq 'boolean') { } 0 37 37
elsif ($type eq 'target') { } 3 34 37
elsif ($type eq 'argv' or $type eq 'keys' or $type eq 'requests') { } 4 30 34
elsif ($type eq 'seconds') { } 0 30 30
elsif ($type eq 'callback') { } 18 12 30
elsif ($type eq 'handle') { } 0 12 12
elsif ($type eq 'environment') { } 0 12 12
Condition66%2/3
$type eq "text" or $type eq "bytes"
l!l&&r!l&&!r
8037
MC/DC50%1/2
$type eq "text" or $type eq "bytes"
$type eq "text" $type eq "bytes"
Truth table66%2/3
A or B
A= $type eq "text"B= $type eq "bytes"
ABresult
1X1
011
000
887 8 ▶ $valid =
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'bytes' ? : 0 8 8
Condition33%2/6
defined $value && !ref($value) && ($type eq 'bytes' ? !utf8::is_utf8($value) : !($value =~ /\0/u))
!ll&&!rl&&r
008
defined $value and not ref $value
!ll&&!rl&&r
008
MC/DC0%0/3
defined $value && !ref($value) && ($type eq 'bytes' ? !utf8::is_utf8($value) : !($value =~ /\0/u))
defined $value not ref $value ($type eq 'bytes' ? !utf8::is_utf8($value) : !($value =~ /\0/u))
Truth table25%1/4
A and not(B) && C
A= defined $valueB= not ref $valueC= ($type eq 'bytes' ? !utf8::is_utf8($value) : !($value =~ /\0/u))
ABCresult
0XX0
10X0
1100
1111
888 defined($value)
889 && !ref($value)
890 && ($type eq 'bytes' ? !utf8::is_utf8($value) : $value !~ /\0/);
891 }
892 ▶ elsif ($type eq 'integer'
Condition33%2/6
$type eq "integer" or $type eq "positive" or $type eq "nonnegative"
l!l&&r!l&&!r
0037
$type eq "integer" or $type eq "positive"
l!l&&r!l&&!r
0037
MC/DC0%0/3
$type eq "integer" or $type eq "positive" or $type eq "nonnegative"
$type eq "integer" $type eq "positive" $type eq "nonnegative"
Truth table25%1/4
A or B or C
A= $type eq "integer"B= $type eq "positive"C= $type eq "nonnegative"
ABCresult
1XX1
01X1
0011
0000
893 || $type eq 'positive'
894 || $type eq 'nonnegative')
895 {
896 0 ▶ $valid =
Condition0%0/9
defined $value && !ref($value) && "$value" =~ /\A-?[0-9]+\z/u && length "$value" < 16
!ll&&!rl&&r
000
defined $value and not ref $value and "$value" =~ /\A-?[0-9]+\z/u
!ll&&!rl&&r
000
defined $value and not ref $value
!ll&&!rl&&r
000
MC/DC0%0/4
defined $value && !ref($value) && "$value" =~ /\A-?[0-9]+\z/u && length "$value" < 16
defined $value not ref $value "$value" =~ /\A-?[0-9]+\z/u length "$value" < 16
Truth table0%0/5
A and not(B) and C && D
A= defined $valueB= not ref $valueC= "$value" =~ /\A-?[0-9]+\z/uD= length "$value" < 16
ABCDresult
0XXX0
10XX0
110X0
11100
11111
897 defined($value)
898 && !ref($value)
899 && "$value" =~ /\A-?[0-9]+\z/
900 && length("$value") < 16;
901 0 ▶ $valid &&= $value > 0 if $type eq 'positive';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "positive" 0 0 0
Condition0%0/3
$valid &&= $value > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$valid &&= $value > 0
$valid $value > 0
Truth table0%0/3
A &&= B
A= $validB= $value > 0
ABresult
0X0
100
111
902 0 ▶ $valid &&= $value >= 0 if $type eq 'nonnegative';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "nonnegative" 0 0 0
Condition0%0/3
$valid &&= $value >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$valid &&= $value >= 0
$valid $value >= 0
Truth table0%0/3
A &&= B
A= $validB= $value >= 0
ABresult
0X0
100
111
903 }
904 elsif ($type eq 'boolean') {
905 0 ▶ $valid =
Condition0%0/12
defined $value && !ref($value) && (JSON::PP::is_bool($value) || "$value" eq '0' || "$value" eq '1')
!ll&&!rl&&r
000
defined $value and not ref $value
!ll&&!rl&&r
000
JSON::PP::is_bool($value) or "$value" eq 0 or "$value" eq 1
l!l&&r!l&&!r
000
JSON::PP::is_bool($value) or "$value" eq 0
l!l&&r!l&&!r
000
MC/DC0%0/5
defined $value && !ref($value) && (JSON::PP::is_bool($value) || "$value" eq '0' || "$value" eq '1')
defined $value not ref $value JSON::PP::is_bool($value) "$value" eq 0 "$value" eq 1
Truth table0%0/6
A and not(B) && C or D or E
A= defined $valueB= not ref $valueC= JSON::PP::is_bool($value)D= "$value" eq 0E= "$value" eq 1
ABCDEresult
0XXXX0
10XXX0
110000
111XX1
1101X1
110011
906 defined($value)
907 && !ref($value)
908 && (JSON::PP::is_bool($value)
909 || "$value" eq '0'
910 || "$value" eq '1');
911 }
912 elsif ($type eq 'target') {
913 3 ▶ $valid = defined($value)
Condition22%2/9
defined $value && (!ref($value) || builtin::blessed($value) && $value->isa('LibTmux::Entity'))
!ll&&!rl&&r
003
not ref $value or builtin::blessed($value) and $value->isa("LibTmux::Entity")
l!l&&r!l&&!r
300
builtin::blessed($value) and $value->isa("LibTmux::Entity")
!ll&&!rl&&r
000
MC/DC0%0/4
defined $value && (!ref($value) || builtin::blessed($value) && $value->isa('LibTmux::Entity'))
defined $value not ref $value builtin::blessed($value) $value->isa("LibTmux::Entity")
Truth table20%1/5
A && not(B) or C and D
A= defined $valueB= not ref $valueC= builtin::blessed($value)D= $value->isa("LibTmux::Entity")
ABCDresult
0XXX0
100X0
10100
11XX1
10111
914 && (!ref($value)
915 || blessed($value) && $value->isa('LibTmux::Entity'));
916 }
917 ▶ elsif ($type eq 'argv' || $type eq 'keys' || $type eq 'requests') {
Condition83%5/6
$type eq "argv" or $type eq "keys" or $type eq "requests"
l!l&&r!l&&!r
4030
$type eq "argv" or $type eq "keys"
l!l&&r!l&&!r
3130
MC/DC66%2/3
$type eq "argv" or $type eq "keys" or $type eq "requests"
$type eq "argv" $type eq "keys" $type eq "requests"
Truth table75%3/4
A or B or C
A= $type eq "argv"B= $type eq "keys"C= $type eq "requests"
ABCresult
1XX1
01X1
0011
0000
918 4 $valid = ref($value) eq 'ARRAY';
919 4 ▶ if ($valid && $type ne 'requests') {
Branch: 1 branch
BranchTrueFalseTotal
if ($valid and $type ne "requests") 4 0 4
Condition33%1/3
$valid and $type ne "requests"
!ll&&!rl&&r
004
MC/DC0%0/2
$valid and $type ne "requests"
$valid $type ne "requests"
Truth table33%1/3
A and B
A= $validB= $type ne "requests"
ABresult
0X0
100
111
920 4 ▶ $valid = !grep { !defined($_) || ref($_) || /\0/ } @$value;
Condition66%4/6
!defined($_) || ref $_ || /\0/u
l!l&&r!l&&!r
103
not defined $_ or ref $_
l!l&&r!l&&!r
013
MC/DC33%1/3
!defined($_) || ref $_ || /\0/u
not defined $_ ref $_ /\0/u
Truth table50%2/4
not(A) or B || C
A= not defined $_B= ref $_C= /\0/u
ABCresult
1XX1
01X1
0011
0000
921 }
922 4 ▶ $valid &&= @$value > 0 if $type eq 'argv';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "argv" 3 1 4
Condition100%3/3
$valid &&= @$value > 0
!ll&&!rl&&r
111
MC/DC100%2/2
$valid &&= @$value > 0
$valid @$value > 0
Truth table100%3/3
A &&= B
A= $validB= @$value > 0
ABresult
0X0
100
111
923 }
924 elsif ($type eq 'seconds') {
925 0 ▶ $valid =
Condition0%0/12
defined $value && !ref($value) && "$value" =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u && $value > 0 && $value <= 86400
!ll&&!rl&&r
000
defined $value and not ref $value and "$value" =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u and $value > 0
!ll&&!rl&&r
000
defined $value and not ref $value and "$value" =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u
!ll&&!rl&&r
000
defined $value and not ref $value
!ll&&!rl&&r
000
MC/DC0%0/5
defined $value && !ref($value) && "$value" =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u && $value > 0 && $value <= 86400
defined $value not ref $value "$value" =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u $value > 0 $value <= 86400
Truth table0%0/6
A and not(B) and C and D && E
A= defined $valueB= not ref $valueC= "$value" =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/uD= $value > 0E= $value <= 86400
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
926 defined($value)
927 && !ref($value)
928 && "$value" =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/
929 && $value > 0
930 && $value <= 86400;
931 }
932 18 elsif ($type eq 'callback') { $valid = ref($value) eq 'CODE' }
933 0 elsif ($type eq 'handle') { $valid = defined(fileno($value)) }
934 elsif ($type eq 'environment') {
935 0 $valid = ref($value) eq 'HASH';
936 0 ▶ if ($valid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($valid) 0 0 0
937 $valid = !grep {
938 0 $_ !~ /\A[A-Za-z_][A-Za-z_0-9]*\z/
939 || !defined($value->{$_})
940 || ref($value->{$_})
941 0 ▶ || $value->{$_} =~ /\0/
Condition0%0/9
!($_ =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u && defined $value->{$_}) || ref $value->{$_} || $value->{$_} =~ /\0/u
l!l&&r!l&&!r
000
not $_ =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u && defined $value->{$_} or ref $value->{$_}
l!l&&r!l&&!r
000
$_ =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u && defined $value->{$_}
!ll&&!rl&&r
000
MC/DC0%0/4
!($_ =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u && defined $value->{$_}) || ref $value->{$_} || $value->{$_} =~ /\0/u
$_ =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/u defined $value->{$_} ref $value->{$_} $value->{$_} =~ /\0/u
Truth table0%0/5
not(A && B) or C || D
A= $_ =~ /\A[A-Za-z_][A-Za-z_0-9]*\z/uB= defined $value->{$_}C= ref $value->{$_}D= $value->{$_} =~ /\0/u
ABCDresult
0XXX1
10XX1
111X1
11011
11000
942 } keys %$value;
943 }
944 }
945 LibTmux::X::InvalidArgument->throw(
946 45 ▶ message => "invalid $name.$key; expected $type")
Branch: 1 branch
BranchTrueFalseTotal
unless $valid 4 41 45
947 unless $valid;
948 }
949 }
950  
951 3 ▶sub _run ($self, $operation) {
Subroutine _run: called CC=3 SCAR=11.7
952 3 my ($value, $error, $finished);
953 $operation->run(
954 0 ▶ sub ($request, $done, $fail) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
955 0 try { $done->(LibTmux::Transport->run(%$request)) }
956 0 catch ($caught) { $fail->($caught) }
957 0 ▶ return sub { };
Subroutine __ANON__: not called CC=1 SCAR=6.9
958 },
959 1 ▶ sub ($result) { $value = $result; $finished = true },
Subroutine __ANON__: called CC=1 SCAR=0.0
960 2 ▶ sub ($caught) { $error = $caught; $finished = true }
Subroutine __ANON__: called CC=1 SCAR=0.0
961 3 );
962 3 ▶ die $error if defined $error;
Branch: 1 branch
BranchTrueFalseTotal
if defined $error 2 1 3
963 1 ▶ LibTmux::X::Transport->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless $finished 0 1 1
964 message => 'synchronous executor did not finish')
965 unless $finished;
966 1 return $value;
967 }
968 1 ▶sub cmd ($self, @argv) { $self->_run($self->operation('cmd', argv => \@argv)) }
Subroutine cmd: called CC=1 SCAR=0.0
Pod documented
969  
970 0 ▶sub listings ($self, $kind) {
Subroutine listings: not called CC=1 SCAR=6.9
Pod documented
971 0 $self->_run($self->operation('listings', kind => $kind));
972 }
973  
974 0 ▶sub batch ($self, $requests) {
Subroutine batch: not called CC=1 SCAR=6.9
Pod documented
975 0 $self->_run($self->operation('batch', requests => $requests));
976 }
977  
978 0 ▶sub attach_argv ($self, %args) {
Subroutine attach_argv: not called CC=3 SCAR=24.8
Pod documented
979 0 $self->_validate_options('attach_argv', \%args);
980 0 my $id = $args{session};
981 0 ▶ LibTmux::X::InvalidArgument->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id and $id =~ /\A\$[0-9]+\z/u 0 0 0
Condition0%0/3
defined $id and $id =~ /\A\$[0-9]+\z/u
!ll&&!rl&&r
000
MC/DC0%0/2
defined $id and $id =~ /\A\$[0-9]+\z/u
defined $id $id =~ /\A\$[0-9]+\z/u
Truth table0%0/3
A and B
A= defined $idB= $id =~ /\A\$[0-9]+\z/u
ABresult
0X0
100
111
982 message => 'attach_argv needs a session ID')
983 unless defined($id) && $id =~ /\A\$[0-9]+\z/;
984 0 return [$self->_prefix, 'attach-session', '-t', $id];
985 }
986  
987 0 ▶sub execute ($self, %args) { $self->_run($self->operation('execute', %args)) }
Subroutine execute: not called CC=1 SCAR=6.9
Pod documented
988  
989 1 ▶sub new_session ($self, %args) {
Subroutine new_session: called CC=1 SCAR=0.0
Pod documented
990 1 $self->_run($self->operation('new_session', %args));
991 }
992  
993 1 ▶sub new_window ($self, %args) {
Subroutine new_window: called CC=1 SCAR=0.0
Pod documented
994 1 $self->_run($self->operation('new_window', %args));
995 }
996  
997 1 ▶sub split_pane ($self, %args) {
Subroutine split_pane: called CC=1 SCAR=0.0
Pod documented
998 1 $self->_run($self->operation('split_pane', %args));
999 }
1000 2 ▶sub snapshot ($self, %args) { $self->_run($self->operation('snapshot', %args)) }
Subroutine snapshot: called CC=1 SCAR=0.0
Pod documented
1001  
1002 1 ▶sub query_panes ($self, %args) {
Subroutine query_panes: called CC=1 SCAR=0.0
Pod documented
1003 1 $self->_run($self->operation('query_panes', %args));
1004 }
1005  
1006 1 ▶sub explain_panes ($self, %args) {
Subroutine explain_panes: called CC=1 SCAR=0.0
Pod documented
1007 1 $self->_run($self->operation('explain_panes', %args));
1008 }
1009  
1010 0 ▶sub rename_session ($self, %args) {
Subroutine rename_session: not called CC=1 SCAR=6.9
Pod documented
1011 0 $self->_run($self->operation('rename_session', %args));
1012 }
1013  
1014 0 ▶sub rename_window ($self, %args) {
Subroutine rename_window: not called CC=1 SCAR=6.9
Pod documented
1015 0 $self->_run($self->operation('rename_window', %args));
1016 }
1017  
1018 0 ▶sub link_window ($self, %args) {
Subroutine link_window: not called CC=1 SCAR=6.9
Pod documented
1019 0 $self->_run($self->operation('link_window', %args));
1020 }
1021  
1022 0 ▶sub unlink_window ($self, %args) {
Subroutine unlink_window: not called CC=1 SCAR=6.9
Pod documented
1023 0 $self->_run($self->operation('unlink_window', %args));
1024 }
1025  
1026 0 ▶sub move_window ($self, %args) {
Subroutine move_window: not called CC=1 SCAR=6.9
Pod documented
1027 0 $self->_run($self->operation('move_window', %args));
1028 }
1029  
1030 0 ▶sub select_window ($self, %args) {
Subroutine select_window: not called CC=1 SCAR=6.9
Pod documented
1031 0 $self->_run($self->operation('select_window', %args));
1032 }
1033  
1034 0 ▶sub select_pane ($self, %args) {
Subroutine select_pane: not called CC=1 SCAR=6.9
Pod documented
1035 0 $self->_run($self->operation('select_pane', %args));
1036 }
1037  
1038 1 ▶sub select_layout ($self, %args) {
Subroutine select_layout: called CC=1 SCAR=0.0
Pod documented
1039 1 $self->_run($self->operation('select_layout', %args));
1040 }
1041  
1042 0 ▶sub resize_pane ($self, %args) {
Subroutine resize_pane: not called CC=1 SCAR=6.9
Pod documented
1043 0 $self->_run($self->operation('resize_pane', %args));
1044 }
1045  
1046 0 ▶sub set_title ($self, %args) {
Subroutine set_title: not called CC=1 SCAR=6.9
Pod documented
1047 0 $self->_run($self->operation('set_title', %args));
1048 }
1049  
1050 0 ▶sub send_keys ($self, %args) {
Subroutine send_keys: not called CC=1 SCAR=6.9
Pod documented
1051 0 $self->_run($self->operation('send_keys', %args));
1052 }
1053  
1054 0 ▶sub send_text ($self, %args) {
Subroutine send_text: not called CC=1 SCAR=6.9
Pod documented
1055 0 $self->_run($self->operation('send_text', %args));
1056 }
1057  
1058 0 ▶sub capture_pane ($self, %args) {
Subroutine capture_pane: not called CC=1 SCAR=6.9
Pod documented
1059 0 $self->_run($self->operation('capture_pane', %args));
1060 }
1061  
1062 0 ▶sub kill_pane ($self, %args) {
Subroutine kill_pane: not called CC=1 SCAR=6.9
Pod documented
1063 0 $self->_run($self->operation('kill_pane', %args));
1064 }
1065  
1066 0 ▶sub kill_window ($self, %args) {
Subroutine kill_window: not called CC=1 SCAR=6.9
Pod documented
1067 0 $self->_run($self->operation('kill_window', %args));
1068 }
1069  
1070 0 ▶sub kill_session ($self, %args) {
Subroutine kill_session: not called CC=1 SCAR=6.9
Pod documented
1071 0 $self->_run($self->operation('kill_session', %args));
1072 }
1073  
1074 0 ▶sub kill_server ($self, %args) {
Subroutine kill_server: not called CC=1 SCAR=6.9
Pod documented
1075 0 $self->_run($self->operation('kill_server', %args));
1076 }
1077 0 ▶sub clients ($self, %args) { $self->_run($self->operation('clients', %args)) }
Subroutine clients: not called CC=1 SCAR=6.9
Pod documented
1078  
1079 0 ▶sub detach_client ($self, %args) {
Subroutine detach_client: not called CC=1 SCAR=6.9
Pod documented
1080 0 $self->_run($self->operation('detach_client', %args));
1081 }
1082  
1083 0 ▶sub set_option ($self, %args) {
Subroutine set_option: not called CC=1 SCAR=6.9
Pod documented
1084 0 $self->_run($self->operation('set_option', %args));
1085 }
1086  
1087 0 ▶sub get_option ($self, %args) {
Subroutine get_option: not called CC=1 SCAR=6.9
Pod documented
1088 0 $self->_run($self->operation('get_option', %args));
1089 }
1090  
1091 0 ▶sub unset_option ($self, %args) {
Subroutine unset_option: not called CC=1 SCAR=6.9
Pod documented
1092 0 $self->_run($self->operation('unset_option', %args));
1093 }
1094 0 ▶sub set_hook ($self, %args) { $self->_run($self->operation('set_hook', %args)) }
Subroutine set_hook: not called CC=1 SCAR=6.9
Pod documented
1095  
1096 0 ▶sub show_hooks ($self, %args) {
Subroutine show_hooks: not called CC=1 SCAR=6.9
Pod documented
1097 0 $self->_run($self->operation('show_hooks', %args));
1098 }
1099  
1100 0 ▶sub set_environment ($self, %args) {
Subroutine set_environment: not called CC=1 SCAR=6.9
Pod documented
1101 0 $self->_run($self->operation('set_environment', %args));
1102 }
1103  
1104 0 ▶sub get_environment ($self, %args) {
Subroutine get_environment: not called CC=1 SCAR=6.9
Pod documented
1105 0 $self->_run($self->operation('get_environment', %args));
1106 }
1107  
1108 0 ▶sub unset_environment ($self, %args) {
Subroutine unset_environment: not called CC=1 SCAR=6.9
Pod documented
1109 0 $self->_run($self->operation('unset_environment', %args));
1110 }
1111  
1112 0 ▶sub set_buffer ($self, %args) {
Subroutine set_buffer: not called CC=1 SCAR=6.9
Pod documented
1113 0 $self->_run($self->operation('set_buffer', %args));
1114 }
1115  
1116 0 ▶sub show_buffer ($self, %args) {
Subroutine show_buffer: not called CC=1 SCAR=6.9
Pod documented
1117 0 $self->_run($self->operation('show_buffer', %args));
1118 }
1119  
1120 0 ▶sub delete_buffer ($self, %args) {
Subroutine delete_buffer: not called CC=1 SCAR=6.9
Pod documented
1121 0 $self->_run($self->operation('delete_buffer', %args));
1122 }
1123  
1124 =head1 NAME
1125  
1126 LibTmux::Server - Explicit tmux acquisition and commands
1127  
1128 =head1 SYNOPSIS
1129  
1130 use v5.44;
1131 use LibTmux::Server;
1132 my $server = LibTmux::Server->new(socket_name => 'application');
1133 my $snapshot = $server->snapshot;
1134 my $pane = $snapshot->panes->first;
1135 say $server->capture_pane(pane => $pane) if defined $pane;
1136  
1137 =head1 CONTRACT
1138  
1139 Construction and planning perform no I/O. Acquisition and mutation are explicit,
1140 bounded operations. Captured L<LibTmux::Snapshot> entities retain their observed
1141 graph; mutations do not refresh them. Acquire another snapshot to observe changes.
1142 Connection settings remain owned by the server wrapper; destroying it never
1143 kills a tmux daemon. See the L<orchestration guide|https://github.com/libtmux/libtmux-perl/blob/master/docs/orchestration.md>.
1144  
1145 Physical entity targets accept stable ID strings or generation-checked handles.
1146 Session-relative window operations require L<LibTmux::WindowLink>. Checks across
1147 subprocesses are optimistic rather than transactional. Single-quote session IDs
1148 such as C<'$1'> to avoid interpolating a Perl capture variable.
1149  
1150 =head1 ERRORS
1151  
1152 Invalid arguments throw L<LibTmux::X/InvalidArgument> before dispatch. Acquisition
1153 and checked commands propagate typed L<LibTmux::X> failures, including missing
1154 executables, absent daemons, vanished targets, stale handles, codec errors,
1155 timeouts, and output limits. Failures never become empty selections. Cancellation
1156 or a timeout after dispatch does not prove nonexecution or roll back effects.
1157  
1158 =head1 METHODS
1159  
1160 =head2 new
1161  
1162 C<new(executable =E<gt> tmux, socket_nameE<verbar>socket_path =E<gt> string, timeout =E<gt> seconds, max_output =E<gt> bytes, config_file =E<gt> path, env =E<gt> hashref)>.
1163  
1164 Return a new server wrapper without I/O. Select socket_name or socket_path,
1165 never both. Defaults are executable tmux, timeout 5 seconds, and an 8 MiB
1166 combined retained-output limit. env is copied; child processes clear ambient
1167 TMUX and TMUX_PANE. Invalid configuration throws
1168 L<LibTmux::X/InvalidArgument>.
1169  
1170 my $server = LibTmux::Server->new(socket_name => 'application');
1171  
1172 =head2 execute
1173  
1174 C<execute(argv =E<gt> arrayref, stdin =E<gt> bytes?, timeout =E<gt> seconds?, cancel_fh =E<gt> handle?)>.
1175  
1176 Perform one raw command and return L<LibTmux::CommandResult>, including
1177 nonzero exits. stdout and stderr remain separate octet strings. stdin is
1178 optional bytes; cancel_fh is borrowed and remains open. Transport failures
1179 throw typed L<LibTmux::X> with bounded partial output when available.
1180  
1181 my $result = $server->execute(argv => ['list-sessions']);
1182  
1183 =head2 cmd
1184  
1185 C<cmd(@literal_arguments)>.
1186  
1187 Perform one checked literal tmux command and return L<LibTmux::CommandResult>.
1188 No shell wrapper or implicit tmux command list is used. Nonzero exits throw
1189 L<LibTmux::X/Command> or a more specific target/server error; transport
1190 failures propagate.
1191  
1192 my $result = $server->cmd('display-message', '-p', '#{version}');
1193  
1194 =head2 new_session
1195  
1196 C<new_session(name =E<gt> string, command =E<gt> arrayref?, shell_command =E<gt> string?, width =E<gt> integer?, height =E<gt> integer?, cwd =E<gt> bytes?, environment =E<gt> hashref?)>.
1197  
1198 Create a detached session and return its captured L<LibTmux::Session>. command
1199 is a literal argument vector; shell_command explicitly requests a shell and is
1200 mutually exclusive. Omitting both uses tmux's default command. cwd is path
1201 octets; environment supplies NAME/value pairs to the first process. Performs
1202 I/O. If creation succeeds but acquisition fails, L<LibTmux::X/Creation>
1203 retains the known generation-scoped creation receipt and cause.
1204  
1205 my $session = $server->new_session(name => 'application', command => ['/bin/cat']);
1206  
1207 =head2 new_window
1208  
1209 C<new_window(session =E<gt> SessionE<verbar>session_id, name =E<gt> string?, command =E<gt> arrayref?, shell_command =E<gt> string?, cwd =E<gt> bytes?, environment =E<gt> hashref?)>.
1210  
1211 Create a detached physical window in the selected session and return its
1212 captured L<LibTmux::Window>. command, shell_command, cwd, and environment
1213 follow L</new_session>. The new link uses tmux's next available index.
1214 Performs I/O; L<LibTmux::X/Creation> preserves known effects if subsequent
1215 acquisition fails.
1216  
1217 my $window = $server->new_window(session => $session, name => 'logs', command => ['/bin/cat']);
1218  
1219 =head2 split_pane
1220  
1221 C<split_pane(pane =E<gt> PaneE<verbar>pane_id, horizontal =E<gt> boolean?, command =E<gt> arrayref?, cwd =E<gt> bytes?, environment =E<gt> hashref?)>.
1222  
1223 Split the targeted pane and return the new captured L<LibTmux::Pane>.
1224 horizontal selects side-by-side placement; false uses tmux's vertical split.
1225 command, shell_command, cwd, and environment follow L</new_session>. Performs
1226 I/O; creation/acquisition failures follow L<LibTmux::X/Creation>.
1227  
1228 my $other = $server->split_pane(pane => $pane, horizontal => true, command => ['/bin/cat']);
1229  
1230 =head2 snapshot
1231  
1232 C<snapshot()>.
1233  
1234 Perform strict graph acquisition and return L<LibTmux::Snapshot>. Physical
1235 windows/panes appear once; L<LibTmux::WindowLink> retains each contextual
1236 association. Capture start/end describe an observation interval, not an atomic
1237 transaction. Acquisition, unsupported capabilities, and incomplete topology
1238 throw typed L<LibTmux::X>; no partial snapshot is returned.
1239  
1240 my $snapshot = $server->snapshot;
1241  
1242 =head2 listings
1243  
1244 C<listings(kind)>.
1245  
1246 Perform acquisition and return a fresh unblessed array reference of contextual
1247 hash records in tmux order, preserving duplicate physical identities. kind is
1248 session, window, pane, or client. An attached-client listing can be empty.
1249 Records are detached values; L</snapshot> normalizes the graph.
1250 Acquisition/codec failures propagate through L<LibTmux::X>.
1251  
1252 my $rows = $server->listings('window');
1253  
1254 =head2 query_panes
1255  
1256 C<query_panes(where =E<gt> criteriaE<verbar>Filter?, pushdown =E<gt> autoE<verbar>neverE<verbar>require?, native_filter =E<gt> string?, on_verification =E<gt> coderef?)>.
1257  
1258 Acquire and return a new L<LibTmux::PaneSelection> in captured physical-pane
1259 order. where accepts a hash reference or L<LibTmux::Filter>. auto verifies
1260 safe scalar candidates after complete local evaluation; never disables the
1261 native comparison. The default auto costs one extra command and supervisor
1262 when lowering is available; it does not reduce acquisition. Select never when
1263 only the captured answer is needed. require throws L<LibTmux::X/Unsupported>
1264 unless lowering is exact, or L<LibTmux::X/QueryMismatch> on disagreement.
1265 native_filter is an exclusive expert escape hatch. Empty successful matches
1266 remain a typed selection; acquisition/evaluation failures propagate.
1267  
1268 C<on_verification> receives one detached report hashref in void context after a
1269 successful decision, including auto fallback. It runs inline once; its return
1270 is ignored and exceptions propagate unchanged unless the operation has already
1271 been cancelled. Cancellation suppresses subsequent result/error delivery.
1272 Failed queries do not invoke it. Report edits cannot change the returned selection. See
1273 L</VERIFICATION REPORT> and L</explain_panes>.
1274  
1275 my $panes = $server->query_panes(where => {active => true}, pushdown => 'auto');
1276  
1277 =head2 explain_panes
1278  
1279 C<explain_panes(where =E<gt> criteriaE<verbar>Filter, pushdown =E<gt> policy?)>.
1280  
1281 Validate criteria and return an inspectable L<LibTmux::QueryPlan> without I/O
1282 or mutation. The plan records required fields/relations, source commands,
1283 residuals, and conditional daemon capability needs. Invalid criteria throw
1284 L<LibTmux::X/InvalidFilter>. Executing L</query_panes> discovers the connected
1285 generation and capabilities.
1286  
1287 my $plan = $server->explain_panes(where => {width => {-gte => 120}});
1288  
1289 =head2 rename_session
1290  
1291 C<rename_session(session =E<gt> SessionE<verbar>session_id, name =E<gt> string)>.
1292  
1293 Rename the selected L<LibTmux::Session> using a literal name. Existing
1294 captured handles keep the old observed name; use L</snapshot> to observe the
1295 change.
1296  
1297 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1298 through L<LibTmux::X>. Captured objects are not modified.
1299  
1300 $server->rename_session(session => $session, name => 'application');
1301  
1302 =head2 rename_window
1303  
1304 C<rename_window(window =E<gt> WindowE<verbar>window_id, name =E<gt> string)>.
1305  
1306 Rename the physical L<LibTmux::Window> across all its links. Names remain
1307 literal rather than expanding tmux formats. Captured handles keep their
1308 observed name.
1309  
1310 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1311 through L<LibTmux::X>. Captured objects are not modified.
1312  
1313 $server->rename_window(window => $window, name => 'logs');
1314  
1315 =head2 link_window
1316  
1317 C<link_window(window =E<gt> WindowE<verbar>window_id, session =E<gt> SessionE<verbar>session_id, index =E<gt> integer?)>.
1318  
1319 Add an association from a physical L<LibTmux::Window> to a
1320 L<LibTmux::Session>. index is optional; conflicts remain command failures.
1321 Existing associations are preserved. Inspect new L<LibTmux::WindowLink>
1322 records through L</snapshot>.
1323  
1324 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1325 through L<LibTmux::X>. Captured objects are not modified.
1326  
1327 $server->link_window(window => $window, session => $session, index => 4);
1328  
1329 =head2 unlink_window
1330  
1331 C<unlink_window(link =E<gt> WindowLinkE<verbar>session_id:index)>.
1332  
1333 Remove exactly one L<LibTmux::WindowLink>, given a captured link or
1334 session_id:index string. Removing the final link can destroy its physical
1335 window; other linked associations retain their context.
1336  
1337 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1338 through L<LibTmux::X>. Captured objects are not modified.
1339  
1340 $server->unlink_window(link => $link);
1341  
1342 =head2 move_window
1343  
1344 C<move_window(link =E<gt> WindowLinkE<verbar>session_id:index, session =E<gt> SessionE<verbar>session_id, index =E<gt> integer?)>.
1345  
1346 Move one contextual L<LibTmux::WindowLink> into the destination session/index.
1347 Other links of the physical window keep their own associations. Use
1348 L</link_window> to add an association without moving one.
1349  
1350 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1351 through L<LibTmux::X>. Captured objects are not modified.
1352  
1353 $server->move_window(link => $link, session => $session, index => 4);
1354  
1355 =head2 select_window
1356  
1357 C<select_window(link =E<gt> WindowLinkE<verbar>session_id:index)>.
1358  
1359 Select a L<LibTmux::WindowLink> within its session. A physical window alone
1360 cannot identify session-relative active state. Capture again through
1361 L</snapshot> to observe the selected link.
1362  
1363 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1364 through L<LibTmux::X>. Captured objects are not modified.
1365  
1366 $server->select_window(link => $link);
1367  
1368 =head2 select_pane
1369  
1370 C<select_pane(pane =E<gt> PaneE<verbar>pane_id)>.
1371  
1372 Change the active L<LibTmux::Pane> of its physical window. This differs from
1373 selecting a session's L<LibTmux::WindowLink>.
1374  
1375 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1376 through L<LibTmux::X>. Captured objects are not modified.
1377  
1378 $server->select_pane(pane => $pane);
1379  
1380 =head2 select_layout
1381  
1382 C<select_layout(window =E<gt> WindowE<verbar>window_id, layout =E<gt> string)>.
1383  
1384 Apply an unambiguous predefined layout name or a checksum-prefixed native
1385 layout to a L<LibTmux::Window>. Unknown or ambiguous predefined names throw
1386 L<LibTmux::X/InvalidArgument> before dispatch, including on tmux 3.3a. Native
1387 custom-layout validation remains tmux's responsibility.
1388  
1389 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1390 through L<LibTmux::X>. Captured objects are not modified.
1391  
1392 $server->select_layout(window => $window, layout => 'tiled');
1393  
1394 =head2 resize_pane
1395  
1396 C<resize_pane(pane =E<gt> PaneE<verbar>pane_id, width =E<gt> positive_integer?, height =E<gt> positive_integer?)>.
1397  
1398 Resize a L<LibTmux::Pane> to the supplied positive width and/or height. tmux's
1399 layout constraints may affect the resulting dimensions; inspect another
1400 L<LibTmux::Snapshot> for observed values.
1401  
1402 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1403 through L<LibTmux::X>. Captured objects are not modified.
1404  
1405 $server->resize_pane(pane => $pane, width => 100);
1406  
1407 =head2 set_title
1408  
1409 C<set_title(pane =E<gt> PaneE<verbar>pane_id, title =E<gt> string)>.
1410  
1411 Set a L<LibTmux::Pane> title. Literal input is protected from format
1412 expansion; tmux's own title sanitization remains observable in a new
1413 L<LibTmux::Snapshot>.
1414  
1415 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1416 through L<LibTmux::X>. Captured objects are not modified.
1417  
1418 $server->set_title(pane => $pane, title => 'build.v2');
1419  
1420 =head2 send_keys
1421  
1422 C<send_keys(pane =E<gt> PaneE<verbar>pane_id, keys =E<gt> arrayref)>.
1423  
1424 Send the array's named keys in order to a L<LibTmux::Pane>. tmux interprets
1425 key names; arguments beginning with a dash remain key operands. An empty array
1426 sends no keys. Acceptance does not prove the pane application consumed input.
1427 Use L</send_text> for literal text.
1428  
1429 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1430 through L<LibTmux::X>. Captured objects are not modified.
1431  
1432 $server->send_keys(pane => $pane, keys => ['Enter']);
1433  
1434 =head2 send_text
1435  
1436 C<send_text(pane =E<gt> PaneE<verbar>pane_id, text =E<gt> stringE<verbar>bytes, enter =E<gt> boolean?)>.
1437  
1438 Send literal text/bytes to a L<LibTmux::Pane>, then optionally send Enter.
1439 Empty text is permitted. Acceptance does not prove application completion. Use
1440 an application-specific observable handshake before relying on output;
1441 L</capture_pane> reads observed terminal content.
1442  
1443 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1444 through L<LibTmux::X>. Captured objects are not modified.
1445  
1446 $server->send_text(pane => $pane, text => 'hello', enter => true);
1447  
1448 =head2 capture_pane
1449  
1450 C<capture_pane(pane =E<gt> PaneE<verbar>pane_id, start =E<gt> integer?, end =E<gt> integer?)>.
1451  
1452 Read a L<LibTmux::Pane> and return raw terminal octets, including tmux's final
1453 newline. Optional start/end select native history rows; no UTF-8 replacement
1454 is performed. This I/O reads current observed content without waiting for
1455 application work. Command/transport failures propagate through L<LibTmux::X>.
1456  
1457 my $bytes = $server->capture_pane(pane => $pane, start => -20);
1458  
1459 =head2 kill_pane
1460  
1461 C<kill_pane(pane =E<gt> PaneE<verbar>pane_id)>.
1462  
1463 Destroy the selected L<LibTmux::Pane>. Killing a window's final pane may
1464 destroy the physical window and its L<LibTmux::WindowLink> associations.
1465 Previously captured records remain readable observations.
1466  
1467 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1468 through L<LibTmux::X>. Captured objects are not modified.
1469  
1470 $server->kill_pane(pane => $pane);
1471  
1472 =head2 kill_window
1473  
1474 C<kill_window(window =E<gt> WindowE<verbar>window_id)>.
1475  
1476 Destroy the physical L<LibTmux::Window> and every L<LibTmux::WindowLink>
1477 referring to it. Use L</unlink_window> when removing one association is the
1478 intended effect.
1479  
1480 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1481 through L<LibTmux::X>. Captured objects are not modified.
1482  
1483 $server->kill_window(window => $window);
1484  
1485 =head2 kill_session
1486  
1487 C<kill_session(session =E<gt> SessionE<verbar>session_id)>.
1488  
1489 Destroy the selected L<LibTmux::Session> and its links. Windows linked
1490 elsewhere can survive. Captured data remains local; later mutations through
1491 stale generation handles are checked.
1492  
1493 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1494 through L<LibTmux::X>. Captured objects are not modified.
1495  
1496 $server->kill_session(session => $session);
1497  
1498 =head2 kill_server
1499  
1500 C<kill_server()>.
1501  
1502 Explicitly request destruction of the connected tmux daemon. This method can
1503 affect a borrowed server and must be called intentionally; wrapper destruction
1504 never calls it. Successful command acceptance alone does not prove every
1505 daemon/client process exited.
1506  
1507 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1508 through L<LibTmux::X>. Captured objects are not modified.
1509  
1510 $server->kill_server;
1511  
1512 =head2 clients
1513  
1514 C<clients()>.
1515  
1516 Acquire a graph and return its L<LibTmux::ClientSelection>. A daemon without
1517 attached clients produces an empty selection. Membership is copied away from
1518 graph storage. Acquisition failures propagate through L<LibTmux::X>;
1519 L</detach_client> changes client state explicitly.
1520  
1521 my $clients = $server->clients;
1522  
1523 =head2 attach_argv
1524  
1525 C<attach_argv(session =E<gt> session_id)>.
1526  
1527 Return a fresh literal argument array for a caller-owned interactive terminal
1528 without I/O. The session target is a stable ID string; obtain it through
1529 L<LibTmux::Session/id>. The caller owns terminal/process setup and exit
1530 observation; the bounded capture transport does not allocate a TTY. Invalid
1531 inputs throw L<LibTmux::X/InvalidArgument>.
1532  
1533 my $argv = $server->attach_argv(session => '$1');
1534  
1535 =head2 detach_client
1536  
1537 C<detach_client(client =E<gt> ClientE<verbar>client_name)>.
1538  
1539 Request detachment of a captured L<LibTmux::Client> or explicit native client
1540 name. Command acceptance can precede client-process exit; callers owning an
1541 attached process must observe its exit separately.
1542  
1543 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1544 through L<LibTmux::X>. Captured objects are not modified.
1545  
1546 $server->detach_client(client => $client);
1547  
1548 =head2 set_option
1549  
1550 C<set_option(name =E<gt> string, value =E<gt> stringE<verbar>integer, scope =E<gt> sessionE<verbar>windowE<verbar>paneE<verbar>server, target =E<gt> id?, global =E<gt> boolean?)>.
1551  
1552 Set an option at explicit session/window/pane/server scope. Supply an exact
1553 target ID for local settings or global => true for the global level. Empty and
1554 zero values are preserved. L</get_option> controls whether inherited values
1555 participate.
1556  
1557 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1558 through L<LibTmux::X>. Captured objects are not modified.
1559  
1560 $server->set_option(scope => 'window', target => $window->id, name => '@build', value => '0');
1561  
1562 =head2 get_option
1563  
1564 C<get_option(name =E<gt> string, scope =E<gt> scope, target =E<gt> id?, global =E<gt> boolean?, inherited =E<gt> boolean?)>.
1565  
1566 Read an option and return its octets, decoding tmux's quoted string values.
1567 Literal backslashes and non-UTF-8 bytes remain distinct on older daemons.
1568 Key, numeric and command options retain native printed syntax. Array values are
1569 joined with newlines in native index order; an empty array returns C<''>.
1570 Empty text and '0' remain values. C<inherited =E<gt> true> requests tmux's
1571 C<-A> behavior; otherwise only the selected local level is queried. Performs
1572 I/O without mutation. Native missing-option errors throw L<LibTmux::X/Command>;
1573 malformed output throws L<LibTmux::X/Codec>. A built-in option without a local
1574 override may produce empty output. See L</set_option> and L</unset_option>.
1575  
1576 my $value = $server->get_option(scope => 'window', target => $window->id, name => '@build');
1577  
1578 =head2 unset_option
1579  
1580 C<unset_option(name =E<gt> string, scope =E<gt> scope, target =E<gt> id?, global =E<gt> boolean?)>.
1581  
1582 Remove the selected local/global option so inheritance can take effect. Scope
1583 and target follow L</set_option>; removing an override differs from assigning
1584 empty text.
1585  
1586 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1587 through L<LibTmux::X>. Captured objects are not modified.
1588  
1589 $server->unset_option(scope => 'window', target => $window->id, name => '@build');
1590  
1591 =head2 set_hook
1592  
1593 C<set_hook(name =E<gt> hook_or_hook[index], command =E<gt> explicit_tmux_command_string, target =E<gt> session_id?, global =E<gt> boolean?)>.
1594  
1595 Set a native hook or sparse hook[index] entry for an explicit session target
1596 or global scope. command is deliberately a tmux command string, unlike literal
1597 process argv. L</show_hooks> preserves native indexes/quoting rather than
1598 inventing a flattened hook list.
1599  
1600 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1601 through L<LibTmux::X>. Captured objects are not modified.
1602  
1603 $server->set_hook(target => $session->id, name => 'after-select-window[3]', command => 'display-message hook');
1604  
1605 =head2 show_hooks
1606  
1607 C<show_hooks(target =E<gt> session_id?, global =E<gt> boolean?)>.
1608  
1609 Read hooks and return raw octets preserving sparse indexes and tmux quoting.
1610 No hooks produce empty text. Performs I/O; failures propagate through
1611 L<LibTmux::X>. See L</set_hook> for explicit command-string semantics.
1612  
1613 my $hooks = $server->show_hooks(target => $session->id);
1614  
1615 =head2 set_environment
1616  
1617 C<set_environment(name =E<gt> env_name, value =E<gt> bytes, session =E<gt> session_target?)>.
1618  
1619 Set a literal environment value for a L<LibTmux::Session> handle or explicit
1620 session ID, or globally when
1621 session is omitted. Empty text and '0' remain values. Existing pane processes
1622 are unaffected; creation-time environment belongs to L</new_session>,
1623 L</new_window>, and L</split_pane>.
1624 Captured handles are checked against the connected daemon generation before
1625 dispatch; stale handles throw L<LibTmux::X/StaleReference>. Raw IDs target the
1626 current session. The probe and mutation remain separate operations.
1627  
1628 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1629 through L<LibTmux::X>. Captured objects are not modified.
1630  
1631 $server->set_environment(session => $session, name => 'BUILD', value => '0');
1632  
1633 =head2 get_environment
1634  
1635 C<get_environment(name =E<gt> env_name, session =E<gt> session_target?)>.
1636  
1637 Read a session/global variable and return its octets. The native quoted
1638 representation is parsed as data; no shell evaluates it. Literal backslashes,
1639 newlines and non-UTF-8 bytes remain distinct. Empty text and '0' remain values.
1640 Performs I/O without mutation; missing or explicitly unset variables throw
1641 L<LibTmux::X/Command>, and malformed output throws L<LibTmux::X/Codec>.
1642 Captured targets follow L</set_environment>'s generation checks.
1643  
1644 my $value = $server->get_environment(session => $session, name => 'BUILD');
1645  
1646 =head2 unset_environment
1647  
1648 C<unset_environment(name =E<gt> env_name, session =E<gt> session_target?)>.
1649  
1650 Unset the named session/global variable. This differs from setting an empty
1651 value; L</get_environment> reports the unset state as a command error.
1652  
1653 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1654 through L<LibTmux::X>. Captured objects are not modified.
1655  
1656 $server->unset_environment(session => $session, name => 'BUILD');
1657  
1658 =head2 set_buffer
1659  
1660 C<set_buffer(name =E<gt> string, data =E<gt> bytes)>.
1661  
1662 Load a named tmux buffer through stdin bytes rather than interpolating data
1663 into a command. Empty data is permitted. L</show_buffer> retrieves bytes;
1664 buffer ownership remains in the daemon until L</delete_buffer> or an external
1665 change.
1666  
1667 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1668 through L<LibTmux::X>. Captured objects are not modified.
1669  
1670 $server->set_buffer(name => 'application', data => "a\0b");
1671  
1672 =head2 show_buffer
1673  
1674 C<show_buffer(name =E<gt> string)>.
1675  
1676 Read a named tmux buffer and return raw octets, including embedded NUL bytes.
1677 Empty data remains an empty string. Performs I/O; a missing buffer throws
1678 L<LibTmux::X/Command>. See L</set_buffer>.
1679  
1680 my $bytes = $server->show_buffer(name => 'application');
1681  
1682 =head2 delete_buffer
1683  
1684 C<delete_buffer(name =E<gt> string)>.
1685  
1686 Delete the named daemon buffer loaded through L</set_buffer>. Other daemon
1687 buffers remain untouched; later L</show_buffer> calls report absence as a
1688 command failure.
1689  
1690 Returns C<undef> after command acceptance. Performs I/O; failures propagate
1691 through L<LibTmux::X>. Captured objects are not modified.
1692  
1693 $server->delete_buffer(name => 'application');
1694  
1695 =head2 batch
1696  
1697 C<batch(arrayref_of_argv)>.
1698  
1699 Perform ordered independent literal requests and return a fresh array
1700 reference of {result, error} records in input order. Each result is
1701 L<LibTmux::CommandResult> or undef; each dispatch error is the original typed
1702 L<LibTmux::X> or undef. Nonzero command exits stay raw results. An empty input
1703 returns an empty array without command I/O. Requests are attempted in order,
1704 without rollback or tmux command-list attribution.
1705  
1706 my $results = $server->batch([['display-message', '-p', '#{version}']]);
1707  
1708 =head2 operation
1709  
1710 C<operation($name, %arguments)> validates and copies arguments, returning one
1711 L<LibTmux::Operation> without I/O. The optional Future facade shares this
1712 preparation and parsing boundary. Use the named methods above for synchronous
1713 execution. Invalid arguments or criteria throw L<LibTmux::X/InvalidArgument>
1714 or L<LibTmux::X/InvalidFilter> before submission.
1715  
1716 my $operation = $server->operation('snapshot');
1717  
1718 =head1 VERIFICATION REPORT
1719  
1720 L</query_panes> supplies a fresh, detached hashref to C<on_verification>.
1721 It contains no entity handles. Every ID array retains stable order; editing
1722 the report cannot mutate captured data or the query result.
1723  
1724 =over 4
1725  
1726 =item C<policy>, C<status>, C<comparison>
1727  
1728 Policy is auto, never, require, or native for the expert escape hatch. Status
1729 is disabled (never), local (no safe lowering), agreed, disagreed, or native.
1730 Comparison is none, exact_ids, candidate_superset, or captured_membership.
1731 Partial lowering checks inclusion of local matches; expert queries check only
1732 membership in the captured graph. Neither establishes full filter equivalence.
1733  
1734 =item C<native_checked>, C<translation_exact>, C<native_filter>, C<reasons>
1735  
1736 native_checked is Boolean. translation_exact is Boolean, or undef for never
1737 and expert queries. native_filter is the executed expression, or undef when no
1738 native check ran. reasons is a fresh arrayref of lowering limitations. Exact
1739 translation and agreement between two observations are separate facts.
1740  
1741 =item C<server_id>, C<generation>, C<daemon_version>, C<capture_start>, C<capture_end>
1742  
1743 Identity strings and the captured interval in wall-clock seconds since the
1744 epoch, from L<LibTmux::Snapshot/metadata>. This is not an atomic observation.
1745  
1746 =item C<captured_ids>, C<local_ids>, C<native_ids>
1747  
1748 captured_ids and local_ids follow physical capture order; local_ids is undef
1749 for expert queries. native_ids holds unique IDs in native first-occurrence
1750 order, or undef when no check ran. An empty array is an observed empty set.
1751  
1752 =item C<missing_ids>, C<unexpected_ids>, C<uncaptured_ids>
1753  
1754 missing_ids lists local matches absent natively, in local order. For exact
1755 lowering, unexpected_ids lists native matches absent locally. uncaptured_ids
1756 lists native IDs absent from the graph. The latter two follow native order;
1757 inapplicable lists are empty. Any applicable mismatch produces disagreed.
1758 L<LibTmux::X/QueryMismatch> carries this report for require or expert failures;
1759 the observer is not called for a failed query. A discrepancy has no inferred
1760 cause: concurrent changes, compiler defects and backend differences all need
1761 investigation.
1762  
1763 =back
1764  
1765 =cut
« LibTmux/Transport.pm ↑ Summary LibTmux/QueryPlan.pm »