| 1 | package Langertha::Raider::CLI::Output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Internal terminal renderer of the raider CLI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 62 | our $VERSION = '0.503'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 62 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 62 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 62 | ▶ | use JSON::MaybeXS (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 62 | ▶ | use Term::ANSIColor qw( colored color ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Palette: blue tones + yellow accents. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 62 | my %PALETTE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | brand => 'bold bright_blue', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | title => 'bold blue', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | prompt => 'bold cyan', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | agent => 'bright_green', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | meta => 'bright_black', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | accent => 'yellow', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | warn => 'yellow', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | err => 'red', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | has out => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 18 | ▶ | default => sub { \*STDOUT }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 62 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 62 | has color => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | builder => '_build_color', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 11 | ▶ | sub _build_color { -t $_[0]->out ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_color: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3932 | ▶ | sub c { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
c: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3932 | my ( $self, $key, @text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3932 | my $text = join '', @text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3932 | ▶ | return $self->color ? colored([ $PALETTE{$key} ], $text) : $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2173 | ▶ | sub emit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2173 | my ( $self, @text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 2173 | print { $self->out } @text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2173 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 88 | ▶ | sub say_agent { $_[0]->emit($_[0]->c(agent => $_[0]->render_inline_code($_[1])), "\n") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_agent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 250 | ▶ | sub say_meta { $_[0]->emit($_[0]->c(meta => $_[1]), "\n") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_meta: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | ▶ | sub say_error { $_[0]->emit($_[0]->c(err => 'error: '), $_[0]->c(warn => $_[1]), "\n") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 46 | ▶ | sub error_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 46 | my ( $self, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 46 | $error = "$error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 46 | $error =~ s/ at (?:\w+ \S+ \(defined at .+ line \d+\)|(?:(?! at ).)+) line \d+\.?\n?\z//s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 46 | chomp $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 46 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 90 | ▶ | sub render_inline_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_inline_code: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 90 | my ( $self, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 90 | ▶ | return $text unless $self->color && !$ENV{ANSI_COLORS_DISABLED}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->color and not $ENV{"ANSI_COLORS_DISABLED"}
MC/DC50%1/2
$self->color and not $ENV{"ANSI_COLORS_DISABLED"}
$self->color
not $ENV{"ANSI_COLORS_DISABLED"}
Truth table66%2/3
A and not(B)
A= $self->colorB= not $ENV{"ANSI_COLORS_DISABLED"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | my $code_on = color('on_grey3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | my $agent_on = color($PALETTE{agent}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | my $reset = color('reset'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | $text =~ s{(?<!`)`([^`\n]+?)`(?!`)}{$code_on$1$reset$agent_on}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 29 | ▶ | sub config_report { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config_report: called CC=42 SCAR=37.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 29 | my ( $self, $report ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 29 | my $json = JSON::MaybeXS->new(canonical => 1, allow_nonref => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | $self->emit($self->c(meta => 'file: '), $self->c(title => $report->{file}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 29 | ▶ | $self->c(meta => $report->{exists} ? '' : ' (not present)'), "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 29 | ▶ | for my $ign (@{ $report->{ignored_files} // [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$report{"ignored_files"} // []
MC/DC100%1/1
$$report{"ignored_files"} // []
$$report{"ignored_files"}
Truth table100%2/2
A
A= $$report{"ignored_files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | $self->emit(' ', $self->c(warn => 'ignored file '.$ign->{file}.': '.$ign->{reason}), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | $self->emit($self->c(meta => 'home: '), $self->c(title => $report->{home_file}), "\n") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 29 | ▶ | if defined $report->{home_file}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 29 | $self->emit($self->c(meta => 'engine: '), $self->c(title => $report->{engine}), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | $self->emit($self->c(meta => 'instructions: '), $self->c(title => $report->{instructions}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 29 | ▶ | $self->c(meta => $report->{bare} ? ' (bare)' : ''), "\n") if defined $report->{instructions}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 29 | ▶ | for my $ign (@{ $report->{ignored_instructions_files} // [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$report{"ignored_instructions_files"} // []
MC/DC100%1/1
$$report{"ignored_instructions_files"} // []
$$report{"ignored_instructions_files"}
Truth table100%2/2
A
A= $$report{"ignored_instructions_files"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | $self->emit(' ', $self->c(warn => 'ignored file '.$ign->{file}.': '.$ign->{reason}), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 29 | for my $v (@{ $report->{values} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 102 | ▶ | my $value = ref $v->{value} ? $json->encode($v->{value}) : $v->{value} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$v{"value"} // ""
MC/DC0%0/1
$$v{"value"} // ""
$$v{"value"}
Truth table50%1/2
A
A= $$v{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 102 | my $from = 'from '.$v->{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 102 | ▶ | $from .= ', merged with '.join(', ', @{ $v->{merged_with} }) if @{ $v->{merged_with} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$$v{"merged_with"} // []
MC/DC100%1/1
$$v{"merged_with"} // []
$$v{"merged_with"}
Truth table100%2/2
A
A= $$v{"merged_with"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 102 | ▶ | $from .= ', overrides '.join(', ', @{ $v->{shadowed} }) if @{ $v->{shadowed} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$v{"shadowed"} // []
MC/DC0%0/1
$$v{"shadowed"} // []
$$v{"shadowed"}
Truth table50%1/2
A
A= $$v{"shadowed"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 102 | ▶ | $from .= ', merged' if $v->{merged}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $self->emit(sprintf(" %s %s %s\n", $self->c(title => sprintf('%-22s', $v->{key})), $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 102 | $self->c(meta => '('.$from.'; '.$v->{applies_to}.')'))); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 29 | for my $ign (@{ $report->{ignored} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 6 | $self->emit(' ', $self->c(warn => 'ignored '.$ign->{key}.': '.$ign->{reason}), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 29 | ▶ | if (my $packs = $report->{packs}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 28 | $self->emit($self->c(meta => 'packs: '), $self->c(meta => '(detection '.$report->{detection}.')'), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 28 | for my $p (@$packs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | $self->emit(sprintf(" %s %-8s %-7s %s\n", $self->c(title => sprintf('%-20s', $p->{name})), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 60 | ▶ | $p->{active} ? 'active' : 'inactive', $p->{origin} // '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$p{"origin"} // ""
MC/DC0%0/1
$$p{"origin"} // ""
$$p{"origin"}
Truth table50%1/2
A
A= $$p{"origin"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | $self->c(meta => $self->pack_reason($p, rule => 1)))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 60 | ▶ | $self->emit(' ', $self->c(warn => 'note: '.$_), "\n") for @{ $p->{detection}{notes} // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$p{"detection"}{"notes"} // []
MC/DC100%1/1
$$p{"detection"}{"notes"} // []
$$p{"detection"}{"notes"}
Truth table100%2/2
A
A= $$p{"detection"}{"notes"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 29 | ▶ | for my $s (@{ $report->{skipped_packs} // [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$report{"skipped_packs"} // []
MC/DC100%1/1
$$report{"skipped_packs"} // []
$$report{"skipped_packs"}
Truth table100%2/2
A
A= $$report{"skipped_packs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | $self->emit(' ', $self->c(warn => 'skipped pack '.$s->{name}.' ('.$s->{origin}.' '.$s->{path}.'): '.$s->{reason}), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 29 | ▶ | if (my $perl = $report->{perl_tools}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | $self->emit($self->c(meta => 'perl tools: '), $perl->{enabled} ? 'on' : 'off', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 28 | ▶ | ' ', $self->c(meta => '('.$perl->{reason}.')'), "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 29 | ▶ | if (my $tools = $report->{tools}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 28 | $self->emit($self->c(meta => 'tools: '), $self->c(meta => '(what a tool can do: information only)'), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 28 | for my $t (@$tools) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 213 | my $fx = $t->{effects}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | $self->emit(sprintf(" %s %-10s %s\n", $self->c(title => sprintf('%-22s', $t->{name})), $t->{source}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 213 | ▶ | $self->c(meta => !$fx ? 'unknown' : @$fx ? join(', ', @$fx) : 'none'))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 29 | ▶ | if (my $pt = $report->{project_tools}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | $self->emit($self->c(meta => 'project tools: '), $self->c(title => $pt->{label}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ' ', $self->c(meta => '(granted by project_tools: information only, nothing is mounted by it)'), "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | ▶ | $self->emit(' ', $self->c(meta => 'selectors:'), "\n") if @{ $pt->{selectors} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | for my $s (@{ $pt->{selectors} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | $self->emit(sprintf(" %s %-11s %s\n", $self->c(title => sprintf('%-20s', $s->{selector})), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | $s->{matched} ? 'matched' : 'not matched', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | ▶ | $self->c(meta => $s->{reason}.( @{ $s->{tools} } ? '; '.join(', ', @{ $s->{tools} }) : '' )))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | $self->emit(' ', $self->c(meta => 'tools:'), "\n") if @{ $pt->{tools} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | for my $t (@{ $pt->{tools} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | my @about = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 3 | ▶ | @{ $t->{requested_by} } ? 'requested by '.join(', ', @{ $t->{requested_by} }) : 'not requested', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$t{"known"} // "unknown"
MC/DC100%1/1
$$t{"known"} // "unknown"
$$t{"known"}
Truth table100%2/2
A
A= $$t{"known"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | ▶ | $t->{known} // 'unknown', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | $self->emit(sprintf(" %s %s %s\n", $self->c(title => sprintf('%-20s', $t->{name})), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 3 | ▶ | @{ $t->{granted_by} } ? 'granted by '.join(', ', @{ $t->{granted_by} }) : 'not granted', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | $self->c(meta => '('.join('; ', @about).')'))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 29 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 11 | ▶ | sub migrate_report { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
migrate_report: called CC=13 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 11 | my ( $self, $plan, %opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 11 | ▶ | unless (@{ $plan->{steps} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | $self->emit($self->c(meta => 'nothing to migrate: no .raider.yml or .raider.md in '.$plan->{root}), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 9 | for my $s (@{ $plan->{steps} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | $self->emit($self->c(title => $s->{from_label}), ' -> ', $self->c(title => $s->{to_label}), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | $self->emit(' ', $self->c(meta => 'backup: '), $s->{backup_label}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 12 | $self->c(meta => ' ('.$s->{from_label}.' is renamed to it)'), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 12 | ▶ | my $lines = $s->{lines}.' line'.( $s->{lines} == 1 ? '' : 's' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | my $content = $s->{rewritten} ? 'rewritten from the parsed YAML, comments and layout are not kept' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 10 | ▶ | : @{ $s->{removed_lines} } ? 'copied without its api_key line'.( @{ $s->{removed_lines} } == 1 ? ' ' : 's ' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 12 | ▶ | .join(', ', @{ $s->{removed_lines} }).' ('.$lines.' left)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | : 'copied unchanged ('.$lines.')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 12 | $self->emit(' ', $self->c(meta => 'content: '), $content, "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 8 | $self->emit(' ', $self->c(warn => 'not copied: api_key in '.join(', ', map { $self->_layer_name($_) } @{ $s->{api_keys} })), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 12 | ▶ | "\n") if @{ $s->{api_keys} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 12 | ▶ | if ($s->{rewritten}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | my $text = $s->{bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | utf8::decode($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | $self->emit(' ', $self->c(meta => '| '), $_, "\n") for split /\n/, $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 9 | ▶ | $self->emit($self->c(meta => 'creates .raider/.gitignore (sessions/, lib/)'), "\n") if $plan->{gitignore}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 9 | ▶ | if (my @keyed = grep { @{ $_->{api_keys} } } @{ $plan->{steps} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | $self->emit($self->c(warn => 'api_key is not copied: .raider/config.yml is meant to be shared, and a project' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | .' must not choose a secret. Put the key into ~/.raider/config.yml (same place) or the engine\'s' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | .' *_API_KEY environment variable. '.join(', ', map { $_->{backup_label} } @keyed) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | .' still holds it: delete the backup once the key is moved.'), "\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 9 | ▶ | $self->emit($self->c(meta => 'dry run: nothing written'), "\n") if $opt{dry_run}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # A layer of Config::explain as the user reads it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 8 | ▶ | sub _layer_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_layer_name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 8 | my ( $self, $layer ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 8 | ▶ | return $layer eq 'top' ? 'the top level' : $layer.':'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 7 | ▶ | sub migrate_done { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
migrate_done: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | my ( $self, @results ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 7 | ▶ | for my $r (grep { !$_->{error} && !$_->{skipped} } @results) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$$_{'error'} || $$_{'skipped'}
MC/DC50%1/2
$$_{'error'} || $$_{'skipped'}
$$_{'error'}
$$_{'skipped'}
Truth table66%2/3
A || B
A= $$_{'error'}B= $$_{'skipped'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 8 | my $s = $r->{step}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | $self->emit('migrated ', $self->c(title => $s->{from_label}), ' -> ', $self->c(title => $s->{to_label}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 8 | $self->c(meta => ' (backup '.$s->{backup_label}.')'), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 72 | ▶ | sub pack_reason { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pack_reason: called CC=8 SCAR=21.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 72 | my ( $self, $p, %opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 72 | my $d = $p->{detection}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | my $text = defined $p->{source} ? $p->{source}.( defined $p->{reason} ? ': '.$p->{reason} : '' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | : $d ? $d->{result}.': '.$d->{reason} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 72 | ▶ | : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | $text .= ' [rule: '.$d->{rule_from}.']' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 72 | ▶ | if $opt{rule} && $d && ( !defined $p->{source} || $p->{source} eq 'detected' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$opt{"rule"} and $d and !defined($$p{"source"}) || $$p{"source"} eq "detected"
$opt{"rule"} and $d
not defined $$p{"source"} or $$p{"source"} eq "detected"
MC/DC50%2/4
$opt{"rule"} and $d and !defined($$p{"source"}) || $$p{"source"} eq "detected"
$opt{"rule"}
$d
not defined $$p{"source"}
$$p{"source"} eq "detected"
Truth table80%4/5
A and B and not(C) or D
A= $opt{"rule"}B= $dC= not defined $$p{"source"}D= $$p{"source"} eq "detected"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 72 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 62 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 62 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | Langertha::Raider::CLI::Output - Internal terminal renderer of the raider CLI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | version 0.503 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # Internal to Langertha-Raider -- no API promise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | my $out = Langertha::Raider::CLI::Output->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | $out->say_meta('history cleared.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | $out->say_error('something failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | $out->say_agent($result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | $out->config_report($app->explain_config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | B<Internal module.> Its interface may change without notice. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | Everything the F<raider> CLI prints for a human goes through here: the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | blue/yellow palette, the agent/meta/error lines, the C<raider config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | explain> report and the C<raider config migrate> report. The machine output (C<--json> and friends) is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | L<Langertha::Raider::CLI::Machine>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | =head2 out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | Filehandle everything is printed to. Defaults to C<STDOUT>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | =head2 color | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | Whether to emit ANSI colors. Defaults to true when L</out> is a terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | C<ANSI_COLORS_DISABLED> switches them off as well. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | =head2 c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | my $text = $out->c(meta => 'some', ' text'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | The text in the palette color C<meta>, C<title>, C<agent>, ... -- plain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | when L</color> is off. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | =head2 emit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | Prints its arguments to L</out>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | =head2 say_agent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | One line of agent output, inline C<`code`> highlighted. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | =head2 say_meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | One line of meta information. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | =head2 say_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | An C<error:> line. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | =head2 error_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | my $text = $out->error_text($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | An exception as one line for the user: without the trailing newline and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | the Perl source location C<croak> appends, also the form Moose adds for a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | constructor or accessor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | =head2 render_inline_code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | Wraps C<`...`> spans in a darker background when colors are on. Triple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | backticks stay untouched so fenced code blocks keep their own flow. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | =head2 config_report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | Prints a report of L<Langertha::Raider::Application/explain_config>: the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | config file in use and any config file ignored next to it (a legacy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | F<.raider.yml> beside F<.raider/config.yml>); the home file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | F<~/.raider/config.yml> when it is loaded; one line per | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | setting with its value, source, what it was merged with, what it overrides | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | and whether it applies to the engine or to raider; the instructions source (C<-M>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | C<.raider/instructions.md>, C<.raider.md>, C<default>) with C<(bare)> under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | C<--bare>, and any instructions file ignored next to the one in use (a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | legacy F<.raider.md> beside F<.raider/instructions.md>); each pack with its state, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | kind of place it was found in (C<project>, C<home>, C<shipped>, C<env>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | and why it is on or off; the pack directories that were skipped, and why; the perl tools grant; and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | each mounted tool with its source and effect classes (C<unknown> for a tool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | the built-in table does not know); and, when F<~/.raider/config.yml> has a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | C<project_tools>, each of its selectors (matched or not, and why) and each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | tool name with the selectors granting it, the packs requesting it and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | whether raider knows it -- information only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | =head2 migrate_report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | $out->migrate_report($plan, dry_run => 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | Prints what C<raider config migrate> does, from a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | L<Langertha::Raider::Config::Migrate/plan> that was not refused: per | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | legacy file its new file, its backup and whether the content changes -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | copied unchanged, without the C<api_key> lines (their line numbers), or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | rewritten (then the new content follows, it holds no C<api_key>) -- and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | where an C<api_key> was left out; whether F<.raider/.gitignore> is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | created; with C<dry_run> that nothing was written. Never prints the value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | of an C<api_key>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | =head2 migrate_done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | $out->migrate_done(@results); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | One line per step of L<Langertha::Raider::Config::Migrate/apply> that was | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | done: C<migrated FROM -E<gt> TO (backup BACKUP)>. Failed and skipped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | steps are the caller's to report. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | =head2 pack_reason | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | my $text = $out->pack_reason($entry, rule => 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | Why a pack of L<Langertha::Raider::Packs::Collection/activation_report> is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | on or off: C<SOURCE: REASON> (C<detected: must file=cpanfile (cpanfile)>, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | C<flag: --no-pack>), or the detection outcome of an inactive pack | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | (C<not matched: ...>). With C<rule> the origin of a detection rule is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | appended (C<[rule: pack default]>). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | =item * L<Langertha::Raider::CLI> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | =head2 Issues | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | L<https://github.com/Getty/langertha-raider/issues>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | =head2 IRC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | =head1 CONTRIBUTING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | This software is copyright (c) 2026 by Torsten Raudssus. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||