| 1 | package Perinci::CmdLine::Plugin::Run::Normal; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # put pragmas + Log::ger here | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 86 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 86 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 86 | ▶ | use Log::ger; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 86 | ▶ | use parent 'Perinci::CmdLine::PluginBase'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | # put other modules alphabetically here | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 86 | ▶ | use IO::Interactive qw(is_interactive); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | # put global variables alphabetically here | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 86 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||
| 14 | 86 | our $DATE = '2023-11-23'; # DATE | |||||||||||||||||||||||||||||||||||||||||
| 15 | 86 | our $DIST = 'Perinci-CmdLine-Lite'; # DIST | |||||||||||||||||||||||||||||||||||||||||
| 16 | 86 | our $VERSION = '1.929'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 85 | ▶ | sub meta { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
meta: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 85 | summary => 'Normal run', | |||||||||||||||||||||||||||||||||||||||||
| 21 | description => <<'_', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | This plugin is included by default, run at the `run` event for a normal run. | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | _ | ||||||||||||||||||||||||||||||||||||||||||
| 26 | conf => { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | prio => 50, # normal | ||||||||||||||||||||||||||||||||||||||||||
| 29 | tags => ['category:run-handler'], | ||||||||||||||||||||||||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 82 | ▶ | sub on_run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_run: called CC=49 SCAR=49.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 82 | my ($self, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 82 | my $co = $r->{common_opts}; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | # set default from common options | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 82 | ▶ | $r->{naked_res} = $co->{naked_res}{default} if $co->{naked_res}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 82 | ▶ | $r->{format} = $co->{format}{default} if $co->{format}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # EXPERIMENTAL, set default format to json if we are running in a pipeline | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # and the right side of the pipe is the 'td' program | ||||||||||||||||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 82 | ▶ | last if is_interactive(*STDOUT) || $r->{format}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
is_interactive(*STDOUT) or $r->{"format"}
MC/DC0%0/2
is_interactive(*STDOUT) or $r->{"format"}
is_interactive(*STDOUT)
$r->{"format"}
Truth table33%1/3
A or B
A= is_interactive(*STDOUT)B= $r->{"format"}
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 82 | ▶ | last unless eval { require Pipe::Find; 1 }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 82 | my $pipeinfo = Pipe::Find::get_stdout_pipe_process(); | |||||||||||||||||||||||||||||||||||||||||
| 48 | 82 | ▶ | last unless $pipeinfo; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | last unless $pipeinfo->{exe} =~ m![/\\]td\z! || | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 82 | ▶ | $pipeinfo->{cmdline} =~ m!\A([^\0]*[/\\])?perl\0([^\0]*[/\\])?td\0!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pipeinfo->{"exe"} =~ m([/\\]td\z) or $pipeinfo->{"cmdline"} =~ m(\A([^\0]*[/\\])?perl\0([^\0]*[/\\])?td\0)
MC/DC0%0/2
$pipeinfo->{"exe"} =~ m([/\\]td\z) or $pipeinfo->{"cmdline"} =~ m(\A([^\0]*[/\\])?perl\0([^\0]*[/\\])?td\0)
$pipeinfo->{"exe"} =~ m([/\\]td\z)
$pipeinfo->{"cmdline"} =~ m(\A([^\0]*[/\\])?perl\0([^\0]*[/\\])?td\0)
Truth table33%1/3
A or B
A= $pipeinfo->{"exe"} =~ m([/\\]td\z)B= $pipeinfo->{"cmdline"} =~ m(\A([^\0]*[/\\])?perl\0([^\0]*[/\\])?td\0)
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $r->{format} = 'json'; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 82 | ▶ | $r->{format} //= $self->cmdline->default_format; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$r->{"format"} //= $self->cmdline->default_format
MC/DC0%0/2
$r->{"format"} //= $self->cmdline->default_format
$r->{"format"}
$self->cmdline->default_format
Truth table33%1/3
A //= B
A= $r->{"format"}B= $self->cmdline->default_format
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 82 | ▶ | if ($self->cmdline->read_config) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | # note that we will be reading config file | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 13 | $r->{read_config} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 82 | ▶ | if ($self->cmdline->read_env) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | # note that we will be reading env for default options | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | $r->{read_env} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 82 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 67 | 82 | log_trace("[pericmd] Running hook_before_run ..."); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 82 | $self->cmdline->hook_before_run($r); | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 82 | log_trace("[pericmd] Running hook_before_parse_argv ..."); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 82 | $self->cmdline->hook_before_parse_argv($r); | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 82 | my $parse_res = $self->cmdline->parse_argv($r); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 81 | ▶ | if ($parse_res->[0] == 501) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | # we'll need to send ARGV to the server, because it's impossible to | ||||||||||||||||||||||||||||||||||||||||||
| 76 | # get args from ARGV (e.g. there's a cmdline_alias with CODE, which | ||||||||||||||||||||||||||||||||||||||||||
| 77 | # has been transformed into string when crossing network boundary) | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $r->{send_argv} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } elsif ($parse_res->[0] != 200) { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | die $parse_res; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 77 | $r->{parse_argv_res} = $parse_res; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 77 | ▶ | $r->{args} = $parse_res->[2] // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$parse_res->[2] // {}
MC/DC100%1/1
$parse_res->[2] // {}
$parse_res->[2]
Truth table100%2/2
A
A= $parse_res->[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | # set defaults | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 77 | ▶ | $r->{action} //= 'call'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$r->{"action"} //= "call"
MC/DC100%1/1
$r->{"action"} //= "call"
$r->{"action"}
Truth table100%2/2
A
A= $r->{"action"}
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # init logging | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 77 | ▶ | if ($self->cmdline->log) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | require Log::ger::App; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $default_level = do { | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my $dry_run = $r->{dry_run} // $self->cmdline->default_dry_run; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$r->{"dry_run"} // $self->cmdline->default_dry_run
MC/DC0%0/2
$r->{"dry_run"} // $self->cmdline->default_dry_run
$r->{"dry_run"}
$self->cmdline->default_dry_run
Truth table0%0/3
A // B
A= $r->{"dry_run"}B= $self->cmdline->default_dry_run
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $dry_run ? 'info' : 'warn'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 95 | Log::ger::App->import( | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | level => $r->{log_level} // $self->cmdline->log_level // $default_level, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
($r->{"log_level"} // $self->cmdline->log_level) // $default_level
$r->{"log_level"} // $self->cmdline->log_level
MC/DC0%0/3
($r->{"log_level"} // $self->cmdline->log_level) // $default_level
$r->{"log_level"}
$self->cmdline->log_level
$default_level
Truth table0%0/4
A // B // C
A= $r->{"log_level"}B= $self->cmdline->log_levelC= $default_level
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | name => $self->cmdline->program_name, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 77 | log_trace("[pericmd] Running hook_after_parse_argv ..."); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 77 | $self->cmdline->hook_after_parse_argv($r); | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 77 | $self->cmdline->parse_cmdline_src($r); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | #log_trace("TMP: parse_res: %s", $parse_res); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 69 | my $missing = $parse_res->[3]{"func.missing_args"}; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 69 | ▶ | die [400, "Missing required argument(s): ".join(", ", @$missing)] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$missing and @$missing
MC/DC100%2/2
$missing and @$missing
$missing
@$missing
Truth table100%3/3
A and B
A= $missingB= @$missing
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | if $missing && @$missing; | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 67 | my $scd = $r->{subcommand_data}; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 67 | ▶ | if ($scd->{pass_cmdline_object} // $self->cmdline->pass_cmdline_object) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$scd->{"pass_cmdline_object"} // $self->cmdline->pass_cmdline_object
MC/DC0%0/2
$scd->{"pass_cmdline_object"} // $self->cmdline->pass_cmdline_object
$scd->{"pass_cmdline_object"}
$self->cmdline->pass_cmdline_object
Truth table66%2/3
A // B
A= $scd->{"pass_cmdline_object"}B= $self->cmdline->pass_cmdline_object
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $r->{args}{-cmdline} = $self->cmdline; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $r->{args}{-cmdline_r} = $r; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 67 | log_trace("[pericmd] Running hook_before_action ..."); | |||||||||||||||||||||||||||||||||||||||||
| 119 | 67 | $self->cmdline->hook_before_action($r); | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 67 | my $meth = "action_$r->{action}"; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 67 | ▶ | die [500, "Unknown action $r->{action}"] unless $self->cmdline->can($meth); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 67 | log_trace("[pericmd] Running %s() ...", $meth); | |||||||||||||||||||||||||||||||||||||||||
| 124 | $self->cmdline->_plugin_run_event( | ||||||||||||||||||||||||||||||||||||||||||
| 125 | name => 'action', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 67 | ▶ | on_success => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 67 | $r->{res} = $self->cmdline->$meth($r); | |||||||||||||||||||||||||||||||||||||||||
| 128 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 67 | ); | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 67 | log_trace("[pericmd] Running hook_after_action ..."); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 67 | $self->cmdline->hook_after_action($r); | |||||||||||||||||||||||||||||||||||||||||
| 133 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 82 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 82 | ▶ | if ($err || !$r->{res}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$err or not $r->{"res"}
MC/DC50%1/2
$err or not $r->{"res"}
$err
not $r->{"res"}
Truth table66%2/3
A or not(B)
A= $errB= not $r->{"res"}
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 15 | ▶ | if ($err) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 15 | ▶ | $err = [500, "Died: $err"] unless ref($err) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 15 | ▶ | if (%Devel::Confess::) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 86 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 15 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 15 | my $id = Scalar::Util::refaddr($err); | |||||||||||||||||||||||||||||||||||||||||
| 143 | 15 | my $stack_trace = $Devel::Confess::MESSAGES{$id}; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 15 | ▶ | $err->[1] .= "\n$stack_trace" if $stack_trace; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 15 | $err->[1] =~ s/\n+$//; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 15 | $r->{res} = $err; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $r->{res} = [500, "Bug: no response produced"]; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | } elsif (ref($r->{res}) ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | log_trace("[pericmd] res=%s", $r->{res}); #2 | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $r->{res} = [500, "Bug in program: result not an array"]; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 82 | ▶ | if (!$r->{res}[0] || $r->{res}[0] < 200 || $r->{res}[0] > 555) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $r->{"res"}[0] or $r->{"res"}[0] < 200 or $r->{"res"}[0] > 555
not $r->{"res"}[0] or $r->{"res"}[0] < 200
MC/DC0%0/3
not $r->{"res"}[0] or $r->{"res"}[0] < 200 or $r->{"res"}[0] > 555
not $r->{"res"}[0]
$r->{"res"}[0] < 200
$r->{"res"}[0] > 555
Truth table25%1/4
not(A) or B or C
A= not $r->{"res"}[0]B= $r->{"res"}[0] < 200C= $r->{"res"}[0] > 555
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $r->{res}[3]{'x.orig_status'} = $r->{res}[0]; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $r->{res}[0] = 555; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | $r->{res}[3]{title} //= join( | ||||||||||||||||||||||||||||||||||||||||||
| 162 | " ", | ||||||||||||||||||||||||||||||||||||||||||
| 163 | $self->cmdline->program_name, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 82 | ▶ | @{ $r->{orig_argv} // \@ARGV }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$r->{"res"}[3]{"title"} //= join(" ", $self->cmdline->program_name, @{$r->{"orig_argv"} // \@ARGV;})
$r->{"orig_argv"} // \@ARGV
MC/DC0%0/1
$r->{"res"}[3]{"title"} //= join(" ", $self->cmdline->program_name, @{$r->{"orig_argv"} // \@ARGV;})
$r->{"res"}[3]{"title"}
MC/DC0%0/1
$r->{"orig_argv"} // \@ARGV
$r->{"orig_argv"}
Truth table50%1/2
A
A= $r->{"res"}[3]{"title"}
Truth table50%1/2
A
A= $r->{"orig_argv"}
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 82 | ▶ | $r->{format} //= $r->{res}[3]{'cmdline.default_format'}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$r->{"format"} //= $r->{"res"}[3]{"cmdline.default_format"}
MC/DC100%2/2
$r->{"format"} //= $r->{"res"}[3]{"cmdline.default_format"}
$r->{"format"}
$r->{"res"}[3]{"cmdline.default_format"}
Truth table100%3/3
A //= B
A= $r->{"format"}B= $r->{"res"}[3]{"cmdline.default_format"}
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 82 | ▶ | $r->{format} //= $r->{meta}{'cmdline.default_format'}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$r->{"format"} //= $r->{"meta"}{"cmdline.default_format"}
MC/DC50%1/2
$r->{"format"} //= $r->{"meta"}{"cmdline.default_format"}
$r->{"format"}
$r->{"meta"}{"cmdline.default_format"}
Truth table66%2/3
A //= B
A= $r->{"format"}B= $r->{"meta"}{"cmdline.default_format"}
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 82 | my $restore_orig_result; | |||||||||||||||||||||||||||||||||||||||||
| 170 | my $orig_result; | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 82 | ▶ | if (exists $r->{res}[3]{'cmdline.result.noninteractive'} && !is_interactive(*STDOUT)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
exists $r->{"res"}[3]{"cmdline.result.noninteractive"} and not is_interactive(*STDOUT)
MC/DC0%0/2
exists $r->{"res"}[3]{"cmdline.result.noninteractive"} and not is_interactive(*STDOUT)
exists $r->{"res"}[3]{"cmdline.result.noninteractive"}
not is_interactive(*STDOUT)
Truth table33%1/3
A and not(B)
A= exists $r->{"res"}[3]{"cmdline.result.noninteractive"}B= not is_interactive(*STDOUT)
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $restore_orig_result = 1; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $orig_result = $r->{res}[2]; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $r->{res}[2] = $r->{res}[3]{'cmdline.result.noninteractive'}; | |||||||||||||||||||||||||||||||||||||||||
| 175 | ▶ | } elsif (exists $r->{res}[3]{'cmdline.result.interactive'} && is_interactive(*STDOUT)) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
exists $r->{"res"}[3]{"cmdline.result.interactive"} and is_interactive(*STDOUT)
MC/DC0%0/2
exists $r->{"res"}[3]{"cmdline.result.interactive"} and is_interactive(*STDOUT)
exists $r->{"res"}[3]{"cmdline.result.interactive"}
is_interactive(*STDOUT)
Truth table33%1/3
A and B
A= exists $r->{"res"}[3]{"cmdline.result.interactive"}B= is_interactive(*STDOUT)
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $restore_orig_result = 1; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $orig_result = $r->{res}[2]; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $r->{res}[2] = $r->{res}[3]{'cmdline.result.interactive'}; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } elsif (exists $r->{res}[3]{'cmdline.result'}) { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | $restore_orig_result = 1; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | $orig_result = $r->{res}[2]; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | $r->{res}[2] = $r->{res}[3]{'cmdline.result'}; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | FORMAT: | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 82 | $self->cmdline->_format($r); | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 82 | ▶ | if ($restore_orig_result) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | $r->{res}[2] = $orig_result; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 82 | my $exitcode; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 82 | ▶ | if ($r->{res}[3] && defined($r->{res}[3]{'cmdline.exit_code'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$r->{"res"}[3] and defined $r->{"res"}[3]{"cmdline.exit_code"}
MC/DC50%1/2
$r->{"res"}[3] and defined $r->{"res"}[3]{"cmdline.exit_code"}
$r->{"res"}[3]
defined $r->{"res"}[3]{"cmdline.exit_code"}
Truth table66%2/3
A and B
A= $r->{"res"}[3]B= defined $r->{"res"}[3]{"cmdline.exit_code"}
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | $exitcode = $r->{res}[3]{'cmdline.exit_code'}; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 81 | $exitcode = $self->cmdline->status2exitcode($r->{res}[0]); | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 82 | ▶ | if ($self->cmdline->exit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 82 | log_trace("[pericmd] exit(%s)", $exitcode); | |||||||||||||||||||||||||||||||||||||||||
| 200 | 82 | exit $exitcode; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | # so this can be tested | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $r->{res}[3]{'x.perinci.cmdline.base.exit_code'} = $exitcode; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->cmdline->_unsetup_progress_output; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | [201]; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 86 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 212 | # ABSTRACT: Normal run | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | __END__ | ||||||||||||||||||||||||||||||||||||||||||