| 1 | package YATT::Lite::CLI; sub MY () {__PACKAGE__} | ||||||||||||||||||||
| 2 | 8 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 8 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 8 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 8 | ▶ | use mro 'c3'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 8 | ▶ | use parent qw(YATT::Lite::Object); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 8 | ▶ | use YATT::Lite::MFields qw/_registry site_opts/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 8 | ▶ | use YATT::Lite::Util::CmdLine qw(parse_opts parse_params); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | #======================================== | ||||||||||||||||||||
| 13 | # Base class for yatt.* command line tools. | ||||||||||||||||||||
| 14 | # | ||||||||||||||||||||
| 15 | # This layer owns argv parsing, policy defaults and output formatting | ||||||||||||||||||||
| 16 | # ONLY. Anything a language server would also need belongs to | ||||||||||||||||||||
| 17 | # YATT::Lite::Site, not here. | ||||||||||||||||||||
| 18 | # | ||||||||||||||||||||
| 19 | # Policy guarantee: this layer never installs $SIG{__DIE__} or | ||||||||||||||||||||
| 20 | # $SIG{__WARN__}. Combined with Site->render_file's default raw-die | ||||||||||||||||||||
| 21 | # policy, `perl -d scripts/yatt.*` keeps its full usefulness. | ||||||||||||||||||||
| 22 | #======================================== | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | # Entry point for scripts: | ||||||||||||||||||||
| 25 | # | ||||||||||||||||||||
| 26 | # exit(YATT::Lite::CLI::Render->run(\@ARGV)); | ||||||||||||||||||||
| 27 | # | ||||||||||||||||||||
| 28 | # Leading --opt=value pairs are configured into the instance, | ||||||||||||||||||||
| 29 | # the rest goes to main(). Returns the exit code. | ||||||||||||||||||||
| 30 | 19 | ▶ | sub run { | ||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 31 | 19 | my ($pack, $list) = @_; | |||||||||||||||||||
| 32 | 19 | my $self = $pack->new($pack->parse_opts($list)); | |||||||||||||||||||
| 33 | 19 | $self->main(@$list); | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | sub main { | ||||||||||||||||||
|
Subroutine
main: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 37 | 0 | my ($self) = @_; | |||||||||||||||||||
| 38 | 0 | croak ref($self) . " must override ->main()"; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | #======================================== | ||||||||||||||||||||
| 42 | # Per-app-root site cache. Tools which take files from multiple sites | ||||||||||||||||||||
| 43 | # (like yatt.genperl or a language server) share one registry. | ||||||||||||||||||||
| 44 | #======================================== | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 9 | ▶ | sub registry { | ||||||||||||||||||
|
Subroutine
registry: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||
| 47 | 9 | my ($self) = @_; | |||||||||||||||||||
| 48 | 9 | ▶ | $self->{_registry} //= do { | ||||||||||||||||||
|
Condition66%2/3
$self->{"_registry"} //= do {
require YATT::Lite::Site::Registry;
"YATT::Lite::Site::Registry"->new($self->{"site_opts"} ? ("default_opts", $self->{"site_opts"}) : ())
}
MC/DC0%0/2
$self->{"_registry"} //= do {
require YATT::Lite::Site::Registry;
"YATT::Lite::Site::Registry"->new($self->{"site_opts"} ? ("default_opts", $self->{"site_opts"}) : ())
}
$self->{"_registry"}
do {
require YATT::Lite::Site::Registry;
"YATT::Lite::Site::Registry"->new($self->{"site_opts"} ? ("default_opts", $self->{"site_opts"}) : ())
}
Truth table66%2/3
A //= B
A= $self->{"_registry"}B= do {
require YATT::Lite::Site::Registry;
"YATT::Lite::Site::Registry"->new($self->{"site_opts"} ? ("default_opts", $self->{"site_opts"}) : ())
}
| |||||||||||||||||||||
| 49 | 8 | require YATT::Lite::Site::Registry; | |||||||||||||||||||
| 50 | YATT::Lite::Site::Registry->new | ||||||||||||||||||||
| 51 | 8 | ▶ | ($self->{site_opts} ? (default_opts => $self->{site_opts}) : ()); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | }; | ||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 9 | ▶ | sub site_for { | ||||||||||||||||||
|
Subroutine
site_for: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 56 | 9 | my ($self, $fn) = @_; | |||||||||||||||||||
| 57 | 9 | $self->registry->site_for($fn); | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 8 | 1; | |||||||||||||||||||