lib/App/Briefing/CLI.pm

filter: Statementstmt 50.4% 171 / 339 Branchbran 36.2% 71 / 196 Conditioncond 33.3% 14 / 42 MC/DCmcdc 15.3% 4 / 26 Subroutinesub 59.4% 22 / 37 Podpod 100% 3 / 3 totaltotal 44.3% 285 / 643 CC 121 SCAR 36.6
CC
121
Cov
44%
_run_doctor
65.9
_run_doctor
65.9
run
61.0
CRAP 38.7
« lib/App/Briefing/Team.pm ↑ Summary lib/App/Briefing/Filesystem.pm »
1 package App::Briefing::CLI;
2 # ABSTRACT: Command-line interface for App::Briefing
3  
4 131 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 131 ▶use App::Briefing;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 131 ▶use App::Briefing::Team;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 131 ▶use Encode qw( encode_utf8 );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 131 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 131 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 131 our $VERSION = '0.006000';
12  
13 131 has _json => ( is => 'lazy', init_arg => undef );
14  
15 185 ▶sub app_class { 'App::Briefing' }
Subroutine app_class: called CC=1 SCAR=0.0
Pod documented
16  
17  
18 31 ▶sub _build__json {
Subroutine _build__json: called CC=1 SCAR=1.2
19 0 ▶ my ( $self ) = @_;
Subroutine _build__json: not called CC=1 SCAR=1.2
20 0 return JSON::MaybeXS->new(
21 allow_nonref => 0,
22 canonical => 1,
23 convert_blessed => 1,
24 utf8 => 1,
25 );
26 }
27  
28 4 ▶sub _usage {
Subroutine _usage: called CC=1 SCAR=1.2
29 0 ▶ my ( $self ) = @_;
Subroutine _usage: not called CC=1 SCAR=1.2
30 0 return <<'USAGE';
31 Usage:
32 briefing hook [subagent-start|pre-tool-use|session-start]
33 briefing hook marketplace-notice
34 briefing doctor [--cwd DIR] [--harness claude|codex|both]
35 briefing doctor --tsv [--cwd DIR]
36 briefing notice
37 briefing --help
38 briefing --version
39 USAGE
40 }
41  
42 69 ▶sub _write_stdout {
Subroutine _write_stdout: called CC=1 SCAR=1.2
43 0 ▶ my ( $self, $text ) = @_;
Subroutine _write_stdout: not called CC=1 SCAR=1.2
44 0 print STDOUT encode_utf8($text);
45 0 return;
46 }
47  
48 15 ▶sub _write_stderr {
Subroutine _write_stderr: called CC=1 SCAR=1.2
49 0 ▶ my ( $self, $text ) = @_;
Subroutine _write_stderr: not called CC=1 SCAR=1.2
50 0 print STDERR encode_utf8($text);
51 0 return;
52 }
53  
54 27 ▶sub _write_json {
Subroutine _write_json: called CC=2 SCAR=9.2
55 0 ▶ my ( $self, $output, $newline ) = @_;
Subroutine _write_json: not called CC=2 SCAR=9.2
56 0 print STDOUT $self->_json->encode($output);
57 0 ▶ print STDOUT "\n" if $newline;
Branch: 2 branches
BranchTrueFalseTotal
if $newline 11 16 27
if $newline 0 0 0
58 0 return;
59 }
60  
61 185 ▶sub _application {
Subroutine _application: called CC=1 SCAR=1.2
62 0 ▶ my ( $self, %attributes ) = @_;
Subroutine _application: not called CC=1 SCAR=1.2
63 0 my $class = $self->app_class;
64 0 return $class->new(%attributes);
65 }
66  
67 131 my %HOOK_EVENTS = (
68 subagentstart => 'SubagentStart',
69 pretooluse => 'PreToolUse',
70 sessionstart => 'SessionStart',
71 );
72  
73 21 ▶sub _hook_event {
Subroutine _hook_event: called CC=1 SCAR=1.2
74 0 ▶ my ( $self, $name ) = @_;
Subroutine _hook_event: not called CC=1 SCAR=1.2
75 0 ( my $key = lc $name ) =~ s/[-_]//g;
76 0 return $HOOK_EVENTS{$key};
77 }
78  
79 20 ▶sub _run_hook {
Subroutine _run_hook: called CC=7 SCAR=28.2
80 0 ▶ my ( $self, $event ) = @_;
Subroutine _run_hook: not called CC=7 SCAR=28.2
81 0 local $/;
82 0 my $raw = <STDIN>;
83 0 ▶ return 0 unless defined $raw && length $raw;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $raw and length $raw 0 20 20
unless defined $raw and length $raw 0 0 0
Condition16%1/6
defined $raw and length $raw
!ll&&!rl&&r
0020
defined $raw and length $raw
!ll&&!rl&&r
000
MC/DC0%0/2
defined $raw and length $raw
defined $raw length $raw
MC/DC0%0/2
defined $raw and length $raw
defined $raw length $raw
Truth table33%1/3
A and B
A= defined $rawB= length $raw
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $rawB= length $raw
ABresult
0X0
100
111
84 0 my $payload = eval { $self->_json->decode($raw) };
85 0 ▶ return 0 unless ref $payload eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $payload eq "HASH" 0 20 20
unless ref $payload eq "HASH" 0 0 0
86  
87 0 ▶ my $result = $self->_application->process_hook(
Branch: 2 branches
BranchTrueFalseTotal
defined $event ? : 15 5 20
defined $event ? : 0 0 0
88 $payload,
89 defined $event ? ( event => $event ) : (),
90 );
91 0 ▶ $self->_write_stderr( $result->{stderr} ) if length $result->{stderr};
Branch: 2 branches
BranchTrueFalseTotal
if length $result->{"stderr"} 4 16 20
if length $result->{"stderr"} 0 0 0
92 0 ▶ $self->_write_json( $result->{output}, 0 ) if defined $result->{output};
Branch: 2 branches
BranchTrueFalseTotal
if defined $result->{"output"} 16 4 20
if defined $result->{"output"} 0 0 0
93 0 return $result->{exit_code};
94 }
95  
96 72 ▶sub _doctor_options {
Subroutine _doctor_options: called CC=15 SCAR=40.9
97 0 ▶ my ( $self, $arguments ) = @_;
Subroutine _doctor_options: not called CC=15 SCAR=40.9
98 0 my %options = ( cwd => '.', harness => 'both', tsv => 0 );
99 0 ▶ while (@{$arguments}) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$arguments;}) 146 70 216
if (@{$arguments;}) 0 0 0
100 0 my $argument = shift @{$arguments};
101 0 ▶ if ($argument eq '--help') {
Branch: 2 branches
BranchTrueFalseTotal
if ($argument eq "--help") 0 146 146
if ($argument eq "--help") 0 0 0
102 0 return ( \%options, undef, 1 );
103 }
104 0 ▶ if ($argument eq '--tsv') {
Branch: 2 branches
BranchTrueFalseTotal
if ($argument eq "--tsv") 71 75 146
if ($argument eq "--tsv") 0 0 0
105 0 $options{tsv} = 1;
106 0 next;
107 }
108 0 ▶ if ($argument eq '--cwd' || $argument eq '--harness') {
Branch: 2 branches
BranchTrueFalseTotal
if ($argument eq "--cwd" or $argument eq "--harness") 74 1 75
if ($argument eq "--cwd" or $argument eq "--harness") 0 0 0
Condition50%3/6
$argument eq "--cwd" or $argument eq "--harness"
l!l&&r!l&&!r
7131
$argument eq "--cwd" or $argument eq "--harness"
l!l&&r!l&&!r
000
MC/DC100%2/2
$argument eq "--cwd" or $argument eq "--harness"
$argument eq "--cwd" $argument eq "--harness"
MC/DC0%0/2
$argument eq "--cwd" or $argument eq "--harness"
$argument eq "--cwd" $argument eq "--harness"
Truth table100%3/3
A or B
A= $argument eq "--cwd"B= $argument eq "--harness"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $argument eq "--cwd"B= $argument eq "--harness"
ABresult
1X1
011
000
109 0 ▶ return ( undef, $argument.' requires a value', 0 ) unless @{$arguments};
Branch: 2 branches
BranchTrueFalseTotal
unless @{$arguments;} 1 73 74
unless @{$arguments;} 0 0 0
110 0 my $key = substr( $argument, 2 );
111 0 $options{$key} = shift @{$arguments};
112 0 next;
113 }
114 0 ▶ if ($argument =~ /\A--(cwd|harness)=(.*)\z/s) {
Branch: 2 branches
BranchTrueFalseTotal
if ($argument =~ /\A--(cwd|harness)=(.*)\z/s) 0 1 1
if ($argument =~ /\A--(cwd|harness)=(.*)\z/s) 0 0 0
115 0 $options{$1} = $2;
116 0 next;
117 }
118 0 return ( undef, 'unknown doctor option: '.$argument, 0 );
119 }
120  
121 return ( undef, '--cwd requires a non-empty value', 0 )
122 0 ▶ unless defined $options{cwd} && length $options{cwd};
Branch: 2 branches
BranchTrueFalseTotal
unless defined $options{"cwd"} and length $options{"cwd"} 0 70 70
unless defined $options{"cwd"} and length $options{"cwd"} 0 0 0
Condition16%1/6
defined $options{"cwd"} and length $options{"cwd"}
!ll&&!rl&&r
0070
defined $options{"cwd"} and length $options{"cwd"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $options{"cwd"} and length $options{"cwd"}
defined $options{"cwd"} length $options{"cwd"}
MC/DC0%0/2
defined $options{"cwd"} and length $options{"cwd"}
defined $options{"cwd"} length $options{"cwd"}
Truth table33%1/3
A and B
A= defined $options{"cwd"}B= length $options{"cwd"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $options{"cwd"}B= length $options{"cwd"}
ABresult
0X0
100
111
123 return ( undef, '--harness must be claude, codex, or both', 0 )
124 unless $options{harness} eq 'claude'
125 || $options{harness} eq 'codex'
126 0 ▶ || $options{harness} eq 'both';
Branch: 2 branches
BranchTrueFalseTotal
unless $options{"harness"} eq "claude" or $options{"harness"} eq "codex" or $options{"harness"} eq "both" 0 70 70
unless $options{"harness"} eq "claude" or $options{"harness"} eq "codex" or $options{"harness"} eq "both" 0 0 0
Condition41%5/12
$options{"harness"} eq "claude" or $options{"harness"} eq "codex" or $options{"harness"} eq "both"
l!l&&r!l&&!r
2680
$options{"harness"} eq "claude" or $options{"harness"} eq "codex"
l!l&&r!l&&!r
1168
$options{"harness"} eq "claude" or $options{"harness"} eq "codex" or $options{"harness"} eq "both"
l!l&&r!l&&!r
000
$options{"harness"} eq "claude" or $options{"harness"} eq "codex"
l!l&&r!l&&!r
000
MC/DC0%0/3
$options{"harness"} eq "claude" or $options{"harness"} eq "codex" or $options{"harness"} eq "both"
$options{"harness"} eq "claude" $options{"harness"} eq "codex" $options{"harness"} eq "both"
MC/DC0%0/3
$options{"harness"} eq "claude" or $options{"harness"} eq "codex" or $options{"harness"} eq "both"
$options{"harness"} eq "claude" $options{"harness"} eq "codex" $options{"harness"} eq "both"
Truth table75%3/4
A or B or C
A= $options{"harness"} eq "claude"B= $options{"harness"} eq "codex"C= $options{"harness"} eq "both"
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/4
A or B or C
A= $options{"harness"} eq "claude"B= $options{"harness"} eq "codex"C= $options{"harness"} eq "both"
ABCresult
1XX1
01X1
0011
0000
127 return ( undef, '--tsv checks the Claude Code team only; use --harness claude or both', 0 )
128 0 ▶ if $options{tsv} && $options{harness} eq 'codex';
Branch: 2 branches
BranchTrueFalseTotal
if $options{"tsv"} and $options{"harness"} eq "codex" 1 69 70
if $options{"tsv"} and $options{"harness"} eq "codex" 0 0 0
Condition50%3/6
$options{"tsv"} and $options{"harness"} eq "codex"
!ll&&!rl&&r
1681
$options{"tsv"} and $options{"harness"} eq "codex"
!ll&&!rl&&r
000
MC/DC100%2/2
$options{"tsv"} and $options{"harness"} eq "codex"
$options{"tsv"} $options{"harness"} eq "codex"
MC/DC0%0/2
$options{"tsv"} and $options{"harness"} eq "codex"
$options{"tsv"} $options{"harness"} eq "codex"
Truth table100%3/3
A and B
A= $options{"tsv"}B= $options{"harness"} eq "codex"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $options{"tsv"}B= $options{"harness"} eq "codex"
ABresult
0X0
100
111
129 0 return ( \%options, undef, 0 );
130 }
131  
132 1 ▶sub _doctor_problems {
Subroutine _doctor_problems: called CC=4 SCAR=20.3
133 0 ▶ my ( $self, $result ) = @_;
Subroutine _doctor_problems: not called CC=4 SCAR=20.3
134 0 my ( @failures, @warnings );
135 0 push @failures, 'unknown skill(s): '.join( ', ', @{ $result->{missing} } )
136 0 ▶ if @{ $result->{missing} };
Branch: 2 branches
BranchTrueFalseTotal
if @{$result->{"missing"};} 1 0 1
if @{$result->{"missing"};} 0 0 0
137 push @failures,
138 '[briefing] table '."\x{2014}".' Codex 0.153+ ignores this whole agent; use # briefing: skills = [...]'
139 0 ▶ if $result->{legacy};
Branch: 2 branches
BranchTrueFalseTotal
if $result->{"legacy"} 0 1 1
if $result->{"legacy"} 0 0 0
140 push @warnings,
141 int( $result->{size} / 1024 ).' kB of skill text, over 64 kB'
142 0 ▶ if $result->{size} > 64 * 1024;
Branch: 2 branches
BranchTrueFalseTotal
if $result->{"size"} > 65536 0 1 1
if $result->{"size"} > 65536 0 0 0
143 0 return ( \@failures, \@warnings );
144 }
145  
146 1 ▶sub _harness_label {
Subroutine _harness_label: called CC=2 SCAR=10.9
147 0 ▶ my ( $self, $harness ) = @_;
Subroutine _harness_label: not called CC=2 SCAR=10.9
148 0 ▶ return $harness eq 'claude' ? 'Claude Code' : 'Codex';
Branch: 2 branches
BranchTrueFalseTotal
$harness eq 'claude' ? : 1 0 1
$harness eq 'claude' ? : 0 0 0
149 }
150  
151 68 ▶sub _run_doctor_tsv {
Subroutine _run_doctor_tsv: called CC=5 SCAR=20.9
152 0 ▶ my ( $self, $base, $cwd ) = @_;
Subroutine _run_doctor_tsv: not called CC=5 SCAR=20.9
153 0 ▶ if (!$base->filesystem->is_dir($cwd)) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($base->filesystem->is_dir($cwd)) 1 67 68
unless ($base->filesystem->is_dir($cwd)) 0 0 0
154 0 $self->_write_stderr(
155 "briefing doctor: '".$cwd."' is not a directory.\n"
156 ."briefing doctor: pass the repository that holds the team.\n"
157 );
158 0 return 2;
159 }
160 0 my $app = $self->_application(
161 cwd => $cwd,
162 home => $base->home,
163 codex_home => $base->codex_home,
164 filesystem => $base->filesystem,
165 );
166 0 my $findings = App::Briefing::Team->new( briefing => $app )->findings;
167 0 my $failed = 0;
168 0 my $text = '';
169 0 for my $finding (@{$findings}) {
170 0 ▶ $failed = 1 if $finding->{status} eq 'missing';
Branch: 2 branches
BranchTrueFalseTotal
if $finding->{"status"} eq "missing" 50 310 360
if $finding->{"status"} eq "missing" 0 0 0
171 0 $text .= join( "\t", @{$finding}{qw( what status name text )} )."\n";
172 }
173 0 $self->_write_stdout($text);
174 0 ▶ return $failed ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
$failed ? : 35 32 67
$failed ? : 0 0 0
175 }
176  
177 72 ▶sub _run_doctor {
Subroutine _run_doctor: called CC=15 SCAR=41.9
178 0 ▶ my ( $self, $arguments ) = @_;
Subroutine _run_doctor: not called CC=15 SCAR=41.9
179 0 my ( $options, $error, $help ) = $self->_doctor_options($arguments);
180 0 ▶ if ($help) {
Branch: 2 branches
BranchTrueFalseTotal
if ($help) 0 72 72
if ($help) 0 0 0
181 0 $self->_write_stdout($self->_usage);
182 0 return 0;
183 }
184 0 ▶ if (defined $error) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $error) 3 69 72
if (defined $error) 0 0 0
185 0 $self->_write_stderr('briefing doctor: '.$error."\n".$self->_usage);
186 0 return 2;
187 }
188  
189 0 my $base = $self->_application;
190 0 my $cwd = $base->filesystem->absolute( $options->{cwd} );
191 0 ▶ return $self->_run_doctor_tsv( $base, $cwd ) if $options->{tsv};
Branch: 2 branches
BranchTrueFalseTotal
if $options->{"tsv"} 68 1 69
if $options->{"tsv"} 0 0 0
192 0 my $app = $self->_application(
193 cwd => $cwd,
194 home => $base->home,
195 codex_home => $base->codex_home,
196 filesystem => $base->filesystem,
197 );
198 0 my $results = $app->check_agents( harness => $options->{harness} );
199 0 my $text = 'briefing doctor '."\x{2014}".' '.$cwd."\n";
200 0 ▶ if (!@{$results}) {
Branch: 2 branches
BranchTrueFalseTotal
unless (@{$results;}) 0 1 1
unless (@{$results;}) 0 0 0
201 0 $self->_write_stdout( $text.' no agents declare skills'."\n" );
202 0 return 0;
203 }
204  
205 my @harnesses = $options->{harness} eq 'both'
206 ? qw( claude codex )
207 0 ▶ : ($options->{harness});
Branch: 2 branches
BranchTrueFalseTotal
$options->{'harness'} eq 'both' ? : 1 0 1
$options->{'harness'} eq 'both' ? : 0 0 0
208 0 my $failed = 0;
209 0 for my $harness (@harnesses) {
210 0 my @entries = grep { $_->{harness} eq $harness } @{$results};
211 0 ▶ next unless @entries;
Branch: 2 branches
BranchTrueFalseTotal
unless @entries 1 1 2
unless @entries 0 0 0
212 0 $text .= "\n".$self->_harness_label($harness)."\n";
213 0 for my $result (@entries) {
214 0 my ( $failures, $warnings ) = $self->_doctor_problems($result);
215 my $where = $app->filesystem->within( $result->{path}, $cwd )
216 ? $app->filesystem->relative( $result->{path}, $cwd )
217 0 ▶ : $result->{path};
Branch: 2 branches
BranchTrueFalseTotal
$app->filesystem->within($result->{'path'}, $cwd) ? : 1 0 1
$app->filesystem->within($result->{'path'}, $cwd) ? : 0 0 0
218 0 ▶ my $status = @{$failures} ? 'FAIL' : @{$warnings} ? 'WARN' : 'ok';
Branch: 4 branches
BranchTrueFalseTotal
@{$failures;} ? : 1 0 1
@{$warnings;} ? : 0 0 0
@{$failures;} ? : 0 0 0
@{$warnings;} ? : 0 0 0
219 0 ▶ $failed = 1 if @{$failures};
Branch: 2 branches
BranchTrueFalseTotal
if @{$failures;} 1 0 1
if @{$failures;} 0 0 0
220 $text .= sprintf " %-4s %s (%s)\n",
221 $status,
222 $result->{agent},
223 0 $where;
224 0 $text .= ' '.join( ', ', @{ $result->{skills} } ).' ('
225 0 .int( $result->{size} / 1024 ).' kB)'."\n";
226 $text .= ' '."\x{2192}".' '.$_."\n"
227 0 for ( @{$failures}, @{$warnings} );
228 }
229 }
230 0 $self->_write_stdout($text);
231 0 ▶ return $failed ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
$failed ? : 1 0 1
$failed ? : 0 0 0
232 }
233  
234 28 ▶sub _run_notice {
Subroutine _run_notice: called CC=4 SCAR=19.6
235 0 ▶ my ( $self ) = @_;
Subroutine _run_notice: not called CC=4 SCAR=19.6
236 # A courtesy note never takes a session down: any failure is silence with exit 0, as in
237 # hooks/briefing-marketplace-notice.
238 0 my $result = eval { $self->_application->process_notice({}) };
239 0 ▶ return 0 unless ref $result eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $result eq "HASH" 0 28 28
unless ref $result eq "HASH" 0 0 0
240 0 ▶ $self->_write_stderr( $result->{stderr} ) if length $result->{stderr};
Branch: 2 branches
BranchTrueFalseTotal
if length $result->{"stderr"} 0 28 28
if length $result->{"stderr"} 0 0 0
241 0 ▶ $self->_write_json( $result->{output}, 1 ) if defined $result->{output};
Branch: 2 branches
BranchTrueFalseTotal
if defined $result->{"output"} 11 17 28
if defined $result->{"output"} 0 0 0
242 0 return $result->{exit_code};
243 }
244  
245 128 ▶sub run {
Subroutine run: called CC=15 SCAR=41.1
Pod documented
246 0 ▶ my ( $invocant, $arguments ) = @_;
Subroutine run: not called CC=15 SCAR=41.1
Pod documented
247 0 ▶ my $self = ref $invocant ? $invocant : $invocant->new;
Branch: 2 branches
BranchTrueFalseTotal
ref $invocant ? : 0 128 128
ref $invocant ? : 0 0 0
248 0 ▶ $arguments = [] unless ref $arguments eq 'ARRAY';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $arguments eq "ARRAY" 0 128 128
unless ref $arguments eq "ARRAY" 0 0 0
249 0 my @arguments = @{$arguments};
250  
251 0 binmode STDIN, ':raw';
252 0 binmode STDOUT, ':raw';
253 0 binmode STDERR, ':raw';
254  
255 0 ▶ my $command = @arguments ? shift @arguments : '--help';
Branch: 2 branches
BranchTrueFalseTotal
@arguments ? : 128 0 128
@arguments ? : 0 0 0
256 0 ▶ if ($command eq '--help' || $command eq 'help') {
Branch: 2 branches
BranchTrueFalseTotal
if ($command eq "--help" or $command eq "help") 0 128 128
if ($command eq "--help" or $command eq "help") 0 0 0
Condition16%1/6
$command eq "--help" or $command eq "help"
l!l&&r!l&&!r
00128
$command eq "--help" or $command eq "help"
l!l&&r!l&&!r
000
MC/DC0%0/2
$command eq "--help" or $command eq "help"
$command eq "--help" $command eq "help"
MC/DC0%0/2
$command eq "--help" or $command eq "help"
$command eq "--help" $command eq "help"
Truth table33%1/3
A or B
A= $command eq "--help"B= $command eq "help"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $command eq "--help"B= $command eq "help"
ABresult
1X1
011
000
257 0 $self->_write_stdout($self->_usage);
258 0 return 0;
259 }
260 0 ▶ if ($command eq '--version') {
Branch: 2 branches
BranchTrueFalseTotal
if ($command eq "--version") 1 127 128
if ($command eq "--version") 0 0 0
261 0 $self->_write_stdout('briefing '.$App::Briefing::VERSION."\n");
262 0 return 0;
263 }
264 0 ▶ if ($command eq 'hook') {
Branch: 6 branches
BranchTrueFalseTotal
if ($command eq 'hook') { } 40 87 127
elsif ($command eq 'doctor') { } 72 15 87
elsif ($command eq 'notice') { } 15 0 15
if ($command eq 'hook') { } 0 0 0
elsif ($command eq 'doctor') { } 0 0 0
elsif ($command eq 'notice') { } 0 0 0
265 0 ▶ return $self->_run_hook if !@arguments;
Branch: 2 branches
BranchTrueFalseTotal
unless @arguments 5 35 40
unless @arguments 0 0 0
266 0 ▶ if (@arguments == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@arguments == 1) 34 1 35
if (@arguments == 1) 0 0 0
267 # The marketplace notice is a SessionStart hook of its own: it owns a state file, which
268 # process_hook never writes. The word is exact, as the starters match it to pick the
269 # notice's fallback.
270 0 ▶ return $self->_run_notice if $arguments[0] eq 'marketplace-notice';
Branch: 2 branches
BranchTrueFalseTotal
if $arguments[0] eq "marketplace-notice" 13 21 34
if $arguments[0] eq "marketplace-notice" 0 0 0
271 0 my $event = $self->_hook_event( $arguments[0] );
272 0 ▶ return $self->_run_hook($event) if defined $event;
Branch: 2 branches
BranchTrueFalseTotal
if defined $event 15 6 21
if defined $event 0 0 0
273 # An unknown EVENT word is hook input, not a usage error: a hook never blocks (exit 0).
274 # Every other malformed command line below stays a usage error (exit 2).
275 0 $self->_write_stderr('briefing: unknown hook event: '.$arguments[0]."\n");
276 0 return 0;
277 }
278 }
279 elsif ($command eq 'doctor') {
280 0 return $self->_run_doctor(\@arguments);
281 }
282 elsif ($command eq 'notice') {
283 0 ▶ return $self->_run_notice if !@arguments;
Branch: 2 branches
BranchTrueFalseTotal
unless @arguments 15 0 15
unless @arguments 0 0 0
284 }
285  
286 0 $self->_write_stderr('briefing: unknown command or arguments'."\n".$self->_usage);
287 0 return 2;
288 }
289  
290  
291  
292 131 1;
293  
294 __END__
« lib/App/Briefing/Team.pm ↑ Summary lib/App/Briefing/Filesystem.pm »