| 1 | package App::PTP::Args; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.022; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use App::PTP::Commands ':CMD'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use App::PTP::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use File::Basename 'dirname'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use File::Spec::Functions 'catfile'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Getopt::Long qw(GetOptionsFromArray :config auto_abbrev no_ignore_case | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 2 | permute auto_version); | |||||||||||||||||||||||||||
| 13 | 2 | ▶ | use List::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Scalar::Util 'looks_like_number'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # Name of files or directory to be processed. This can also contain a reference | ||||||||||||||||||||||||||||
| 20 | # to the $stdin_marker variable, to indicate that the standard input needs to be | ||||||||||||||||||||||||||||
| 21 | # processed. | ||||||||||||||||||||||||||||
| 22 | 2 | my @inputs; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # The list of actions applied to the input. This is a list of array reference. | ||||||||||||||||||||||||||||
| 25 | # Each of these array will contain the name of the command to run, the coderef | ||||||||||||||||||||||||||||
| 26 | # for it, and then its arguments if any. | ||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||
| 28 | # There are two lists, the set of actions that happens before the --merge flag | ||||||||||||||||||||||||||||
| 29 | # and the set of action that happens after. | ||||||||||||||||||||||||||||
| 30 | my @pre_merge_pipeline; | ||||||||||||||||||||||||||||
| 31 | 2 | my @post_merge_pipeline; | |||||||||||||||||||||||||||
| 32 | 2 | my $cur_pipeline = \@pre_merge_pipeline; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # This hash contains options that are used during the pipeline and that can be | ||||||||||||||||||||||||||||
| 35 | # set or un-set for each command. | ||||||||||||||||||||||||||||
| 36 | 2 | my %modes; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # This hash contains options that are global for the whole program. | ||||||||||||||||||||||||||||
| 39 | # Note that --merge is an option because it impacts the way the final result is | ||||||||||||||||||||||||||||
| 40 | # handled (and has compatibility limitations with other options), but it also | ||||||||||||||||||||||||||||
| 41 | # impact the way the pipeline is built. | ||||||||||||||||||||||||||||
| 42 | my %options; | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 2 | my $default_input_field = '\s*,\s*|\t'; | |||||||||||||||||||||||||||
| 45 | 2 | my $default_output_field = "\t"; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # env(foo => default) | ||||||||||||||||||||||||||||
| 48 | # Returns the given environment variable or the default value. | ||||||||||||||||||||||||||||
| 49 | # Always return the default value if the HARNESS_ACTIVE variable is set (so that | ||||||||||||||||||||||||||||
| 50 | # tests are not affected by environment variables). | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub env { | ||||||||||||||||||||||||||
|
Subroutine
env: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 0 | my ($var, $default) = @_; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | return $default if $ENV{HARNESS_ACTIVE}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | return $ENV{$var} // $default; | ||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{$var} // $default
MC/DC0%0/2
$ENV{$var} // $default
$ENV{$var}
$default
Truth table0%0/3
A // B
A= $ENV{$var}B= $default
| |||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub get_default_modes { | ||||||||||||||||||||||||||
|
Subroutine
get_default_modes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 58 | 0 | my %m; | |||||||||||||||||||||||||||
| 59 | 0 | $m{case_sensitive} = not(env(PTP_DEFAULT_CASE_INSENSITIVE => 0)); | |||||||||||||||||||||||||||
| 60 | 0 | $m{quote_regex} = env(PTP_DEFAULT_QUOTE_REGEX => 0); | |||||||||||||||||||||||||||
| 61 | 0 | $m{global_match} = not(env(PTP_DEFAULT_LOCAL_MATCH => 0)); | |||||||||||||||||||||||||||
| 62 | 0 | $m{comparator} = \'default'; | |||||||||||||||||||||||||||
| 63 | 0 | $m{regex_engine} = env(PTP_DEFAULT_REGEX_ENGINE => 'perl'); | |||||||||||||||||||||||||||
| 64 | 0 | $m{fatal_error} = env(PTP_DEFAULT_FATAL_ERROR => 0); | |||||||||||||||||||||||||||
| 65 | 0 | $m{inverse_match} = env(PTP_DEFAULT_INVERSE_MATCH => 0); | |||||||||||||||||||||||||||
| 66 | 0 | $m{input_field} = $default_input_field; | |||||||||||||||||||||||||||
| 67 | 0 | $m{output_field} = $default_output_field; | |||||||||||||||||||||||||||
| 68 | 0 | return %m; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub get_default_options { | ||||||||||||||||||||||||||
|
Subroutine
get_default_options: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | 0 | my %o; | |||||||||||||||||||||||||||
| 73 | 0 | $o{input_encoding} = 'UTF-8'; | |||||||||||||||||||||||||||
| 74 | 0 | $o{output_encoding} = 'UTF-8'; | |||||||||||||||||||||||||||
| 75 | 0 | $o{input_separator} = '\n'; # This will be interpreted in a regex | |||||||||||||||||||||||||||
| 76 | 0 | $o{output_separator} = "\n"; | |||||||||||||||||||||||||||
| 77 | 0 | $o{preserve_eol} = 0; | |||||||||||||||||||||||||||
| 78 | 0 | $o{fix_final_separator} = 0; | |||||||||||||||||||||||||||
| 79 | 0 | $o{recursive} = 0; | |||||||||||||||||||||||||||
| 80 | 0 | $o{input_filter} = undef; | |||||||||||||||||||||||||||
| 81 | 0 | $o{debug_mode} = 0; | |||||||||||||||||||||||||||
| 82 | 0 | $o{merge} = 0; | |||||||||||||||||||||||||||
| 83 | 0 | $o{in_place} = 0; | |||||||||||||||||||||||||||
| 84 | 0 | $o{output} = undef; | |||||||||||||||||||||||||||
| 85 | 0 | $o{append} = 0; | |||||||||||||||||||||||||||
| 86 | 0 | $o{abort} = 0; | |||||||||||||||||||||||||||
| 87 | 0 | $o{preserve_perl_env} = 0; | |||||||||||||||||||||||||||
| 88 | 0 | $o{use_safe} = env(PTP_DEFAULT_SAFE => 0); | |||||||||||||||||||||||||||
| 89 | 0 | return %o; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | # Resets all the global variables used for the command line parsing. This is | ||||||||||||||||||||||||||||
| 93 | # really useful only in tests. | ||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub reset_global { | ||||||||||||||||||||||||||
|
Subroutine
reset_global: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 0 | @inputs = (); | |||||||||||||||||||||||||||
| 96 | 0 | @pre_merge_pipeline = (); | |||||||||||||||||||||||||||
| 97 | 0 | @post_merge_pipeline = (); | |||||||||||||||||||||||||||
| 98 | 0 | %modes = get_default_modes(); | |||||||||||||||||||||||||||
| 99 | 0 | %options = get_default_options(); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub set_output { | ||||||||||||||||||||||||||
|
Subroutine
set_output: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 103 | 0 | my (undef, $f) = @_; | |||||||||||||||||||||||||||
| 104 | 0 | ▶ | if (defined $options{output}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | die "Only a single occurrence of --output or --append is allowed.\n"; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 0 | $options{output} = $f; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub find_cheat_sheet { | ||||||||||||||||||||||||||
|
Subroutine
find_cheat_sheet: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 111 | 0 | my $cur_file = (__PACKAGE__ =~ s{::}{/}rg).'.pm'; | |||||||||||||||||||||||||||
| 112 | 0 | ▶ | die "Failed to find file for the current module (${cur_file})\n" unless exists $INC{$cur_file}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 0 | my $p = catfile(dirname($INC{$cur_file}), 'Cheat_Sheet.pod'); | |||||||||||||||||||||||||||
| 114 | 0 | ▶ | die "Cannot find Cheat Sheet file: ${p}\n" unless -f $p; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | return $p; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 1 | ▶ | sub options_flags { | ||||||||||||||||||||||||||
|
Subroutine
options_flags: called CC=1 SCAR=2.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 119 | ( | ||||||||||||||||||||||||||||
| 120 | 0 | ▶ | 'help|helplong|h' => sub { pod2usage(-exitval => 0, -verbose => 2) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | 'helpshort' => sub { pod2usage(-exitval => 0, -verbose => 0) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | 'cheat' => sub { pod2usage(-exitval => 0, -verbose => 2, -input => find_cheat_sheet()) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 123 | 'debug|d+' => \$options{debug_mode}, | ||||||||||||||||||||||||||||
| 124 | # Merge is documented to be a pipeline command, but it is implemented as a | ||||||||||||||||||||||||||||
| 125 | # very custom option. | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | 'merge|m' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | die "The --merge option can only be specified once\n" if $options{merge}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 0 | $options{merge} = 1; | |||||||||||||||||||||||||||
| 129 | 0 | $cur_pipeline = \@post_merge_pipeline; | |||||||||||||||||||||||||||
| 130 | }, | ||||||||||||||||||||||||||||
| 131 | 'in-place|i!' => \$options{in_place}, | ||||||||||||||||||||||||||||
| 132 | 'output|o=s' => \&set_output, | ||||||||||||||||||||||||||||
| 133 | 0 | ▶ | 'append|a=s' => sub { set_output(@_); $options{append} = 1; }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 134 | 'abort!' => \$options{abort}, | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 'recursive|R|r!' => \$options{recursive}, | ||||||||||||||||||||||||||||
| 137 | 'input-filter=s' => \$options{input_filter}, | ||||||||||||||||||||||||||||
| 138 | 'input-encoding|in-encoding=s' => \$options{input_encoding}, | ||||||||||||||||||||||||||||
| 139 | 'output-encoding|out-encoding=s' => \$options{output_encoding}, | ||||||||||||||||||||||||||||
| 140 | 'input-separator|in-separator=s' => \$options{input_separator}, | ||||||||||||||||||||||||||||
| 141 | 'output-separator|out-separator=s' => \$options{output_separator}, | ||||||||||||||||||||||||||||
| 142 | 'fix-final-separator!' => \$options{fix_final_separator}, | ||||||||||||||||||||||||||||
| 143 | # TODO: add more tests for this mode, it’s unclear that the input separator | ||||||||||||||||||||||||||||
| 144 | # is really used (also work if it’s set to something else). | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | '0' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | $options{input_separator} = "\N{NULL}"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 147 | 0 | $options{output_separator} = ''; | |||||||||||||||||||||||||||
| 148 | }, | ||||||||||||||||||||||||||||
| 149 | 0 | ▶ | '00' => sub { $options{output_separator} = "\N{NULL}" }, | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 150 | 'preserve-input-separator|eol' => | ||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub { $options{preserve_eol} = 1; $options{output_separator} = '' }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 152 | 'preserve-perl-env!' => \$options{preserve_perl_env}, | ||||||||||||||||||||||||||||
| 153 | 0 | ▶ | 'safe:2' => sub { $options{use_safe} = $_[1] },) | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 154 | 1 | } | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 1 | ▶ | sub modes_flags { | ||||||||||||||||||||||||||
|
Subroutine
modes_flags: called CC=1 SCAR=6.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 157 | ( | ||||||||||||||||||||||||||||
| 158 | 0 | ▶ | 'case-sensitive|S' => sub { $modes{case_sensitive} = 1 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 159 | 0 | ▶ | 'case-insensitive|I' => sub { $modes{case_sensitive} = 0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | 'quote-regexp|Q' => sub { $modes{quote_regex} = 1 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | 'end-quote-regexp|E' => sub { $modes{quote_regex} = 0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | 'global-match|G' => sub { $modes{global_match} = 1 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | 'local-match|L' => sub { $modes{global_match} = 0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 164 | 0 | ▶ | 'comparator|C=s' => sub { $modes{comparator} = $_[1] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | 'regex-engine|re=s' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 166 | 0 | ▶ | die "Invalid value for --regex-engine: $_[1]\n" if $_[1] !~ /^\w+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 0 | $modes{regex_engine} = $_[1]; | |||||||||||||||||||||||||||
| 168 | }, | ||||||||||||||||||||||||||||
| 169 | 0 | ▶ | 'fatal-error|X' => sub { $modes{fatal_error} = 1 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 170 | 0 | ▶ | 'ignore-error' => sub { $modes{fatal_error} = 0 }, # Find a short option? | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | 'inverse-match|V' => sub { $modes{inverse_match} = 1 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | 'normal-match|N' => sub { $modes{inverse_match} = 0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | 'input-field-separator|F=s' => sub { $modes{input_field} = $_[1] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 174 | 'output-field-separator|P=s' => \$modes{output_field}, | ||||||||||||||||||||||||||||
| 175 | 0 | ▶ | 'default' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 176 | 0 | $modes{input_field} = $default_input_field; | |||||||||||||||||||||||||||
| 177 | 0 | $modes{output_field} = $default_output_field; | |||||||||||||||||||||||||||
| 178 | }, | ||||||||||||||||||||||||||||
| 179 | 0 | ▶ | 'bytes' => sub { $modes{input_field} = ''; $modes{output_field} = ''; }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | 'csv' => sub { $modes{input_field} = '\s*,\s*'; $modes{output_field} = ','; }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | 'tsv' => sub { $modes{input_field} = '\t'; $modes{output_field} = "\t"; }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 182 | 0 | ▶ | 'none' => sub { $modes{input_field} = '(?!)' }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 183 | 0 | ▶ | 'single-quote-replacement|single-quote|sq=s' => sub { $modes{single_quote} = $_[1] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 184 | 0 | ▶ | 'double-quote-replacement|double-quote|dq=s' => sub { $modes{double_quote} = $_[1] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 185 | 0 | ▶ | 'dollar-sigil-replacement|dollar-sigil|ds=s' => sub { $modes{dollar_sigil} = $_[1] },) | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 186 | 1 | } | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 1 | ▶ | sub input_flags { | ||||||||||||||||||||||||||
|
Subroutine
input_flags: called CC=1 SCAR=2.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 189 | ( | ||||||||||||||||||||||||||||
| 190 | 0 | ▶ | '<>' => sub { push @inputs, $_[0] }, # Any options not matched otherwise. | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 191 | 0 | ▶ | '' => sub { push @inputs, \$App::PTP::Files::stdin_marker }, # a single '-' | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 192 | ) | ||||||||||||||||||||||||||||
| 193 | 1 | } | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub is_int { | ||||||||||||||||||||||||||
|
Subroutine
is_int: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 196 | 0 | my ($str) = @_; | |||||||||||||||||||||||||||
| 197 | 0 | ▶ | return looks_like_number($str) && int($str) == $str; | ||||||||||||||||||||||||||
|
Condition0%0/3
&looks_like_number($str) && int $str == $str
MC/DC0%0/2
&looks_like_number($str) && int $str == $str
&looks_like_number($str)
int $str == $str
Truth table0%0/3
A && B
A= &looks_like_number($str)B= int $str == $str
| |||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub validate_cut_spec { | ||||||||||||||||||||||||||
|
Subroutine
validate_cut_spec: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 201 | 0 | my ($spec) = @_; | |||||||||||||||||||||||||||
| 202 | 0 | my @fields = split /\s*,\s*/, $spec; | |||||||||||||||||||||||||||
| 203 | 0 | for my $f (@fields) { | |||||||||||||||||||||||||||
| 204 | 0 | ▶ | die "Fields passed to --cut must all be integers: $f\n" unless is_int($f); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | $f-- if $f > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | 0 | return \@fields; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | # The array associated with each action contains the name of the action, the | ||||||||||||||||||||||||||||
| 211 | # method to call for that action, a copy of the current %modes, and all the | ||||||||||||||||||||||||||||
| 212 | # other arguments that should be passed to the method. | ||||||||||||||||||||||||||||
| 213 | 1 | ▶ | sub action_flags { | ||||||||||||||||||||||||||
|
Subroutine
action_flags: called CC=1 SCAR=6.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 214 | ( | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | 'grep|g=s' => sub { push @{$cur_pipeline}, ['grep', \&do_grep, {%modes}, $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 216 | 0 | ▶ | 'substitute|s=s{2}' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 217 | 0 | push @{$cur_pipeline}, ['substitute', \&do_substitute, {%modes}, $_[1]]; | |||||||||||||||||||||||||||
| 218 | }, | ||||||||||||||||||||||||||||
| 219 | # All the do_perl below could have the same sub using "$_[0]" instead of the | ||||||||||||||||||||||||||||
| 220 | # manually specified name. | ||||||||||||||||||||||||||||
| 221 | 0 | ▶ | 'perl|p=s' => sub { push @{$cur_pipeline}, ['perl', \&do_perl, {%modes}, 'perl', $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | 'n=s' => sub { push @{$cur_pipeline}, ['n', \&do_perl, {%modes}, 'n', $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 223 | 0 | ▶ | 'filter|f=s' => sub { push @{$cur_pipeline}, ['filter', \&do_perl, {%modes}, 'filter', $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 224 | 0 | ▶ | 'mark-line|ml=s' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 225 | 0 | push @{$cur_pipeline}, ['mark-line', \&do_perl, {%modes}, 'mark-line', $_[1]]; | |||||||||||||||||||||||||||
| 226 | }, | ||||||||||||||||||||||||||||
| 227 | 0 | ▶ | 'execute|e=s' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 228 | 0 | push @{$cur_pipeline}, ['execute', \&do_execute, {%modes}, 'execute', $_[1]]; | |||||||||||||||||||||||||||
| 229 | }, | ||||||||||||||||||||||||||||
| 230 | 0 | ▶ | 'M=s' => sub { push @{$cur_pipeline}, ['M', \&do_execute, {%modes}, 'M', $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | 'load|l=s' => sub { push @{$cur_pipeline}, ['load', \&do_load, {%modes}, $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | 'sort' => sub { push @{$cur_pipeline}, ['sort', \&do_sort, {%modes}] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 233 | 0 | ▶ | 'numeric-sort|ns' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 234 | 0 | my $opt = {%modes, comparator => \'numeric'}; | |||||||||||||||||||||||||||
| 235 | 0 | push @{$cur_pipeline}, ['numeric-sort', \&do_sort, $opt]; | |||||||||||||||||||||||||||
| 236 | }, | ||||||||||||||||||||||||||||
| 237 | 0 | ▶ | 'locale-sort|ls' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 238 | 0 | my $opt = {%modes, comparator => \'locale'}; | |||||||||||||||||||||||||||
| 239 | 0 | push @{$cur_pipeline}, ['locale-sort', \&do_sort, $opt]; | |||||||||||||||||||||||||||
| 240 | }, | ||||||||||||||||||||||||||||
| 241 | 0 | ▶ | 'version-sort|vs' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 242 | 0 | my $opt = {%modes, comparator => \'semver'}; | |||||||||||||||||||||||||||
| 243 | 0 | push @{$cur_pipeline}, ['version-sort', \&do_sort, $opt]; | |||||||||||||||||||||||||||
| 244 | }, | ||||||||||||||||||||||||||||
| 245 | 0 | ▶ | 'custom-sort|cs=s' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 246 | 0 | my $opt = {%modes, comparator => $_[1]}; | |||||||||||||||||||||||||||
| 247 | 0 | push @{$cur_pipeline}, ['custom-sort', \&do_sort, $opt]; | |||||||||||||||||||||||||||
| 248 | }, | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | 'unique|uniq|u' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 250 | 0 | push @{$cur_pipeline}, | |||||||||||||||||||||||||||
| 251 | ['unique', \&do_list_op, {%modes}, \&App::PTP::Util::uniqstr, 'together']; | ||||||||||||||||||||||||||||
| 252 | }, | ||||||||||||||||||||||||||||
| 253 | 0 | ▶ | 'global-unique|guniq|gu' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 254 | 0 | push @{$cur_pipeline}, | |||||||||||||||||||||||||||
| 255 | ['global-unique', \&do_list_op, {%modes}, \&App::PTP::Util::globaluniqstr, 'together']; | ||||||||||||||||||||||||||||
| 256 | }, | ||||||||||||||||||||||||||||
| 257 | 0 | ▶ | 'head:i' => sub { push @{$cur_pipeline}, ['head', \&do_head, {%modes}, $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | 'tail:i' => sub { push @{$cur_pipeline}, ['tail', \&do_tail, {%modes}, $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 259 | 0 | ▶ | 'reverse|tac' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 260 | 0 | ▶ | push @{$cur_pipeline}, ['reverse', \&do_list_op, {%modes}, sub { reverse @_ }, 'same']; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 261 | }, | ||||||||||||||||||||||||||||
| 262 | 0 | ▶ | 'shuffle' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 263 | 0 | push @{$cur_pipeline}, ['shuffle', \&do_list_op, {%modes}, \&List::Util::shuffle, 'none']; | |||||||||||||||||||||||||||
| 264 | }, | ||||||||||||||||||||||||||||
| 265 | 0 | ▶ | 'eat' => sub { push @{$cur_pipeline}, ['eat', \&do_eat, {%modes}] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 266 | 0 | ▶ | 'delete-marked' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 267 | 0 | push @{$cur_pipeline}, ['delete-marked', \&do_delete_marked, {%modes}, 0]; | |||||||||||||||||||||||||||
| 268 | }, | ||||||||||||||||||||||||||||
| 269 | 0 | ▶ | 'delete-before' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 270 | 0 | push @{$cur_pipeline}, ['delete-before', \&do_delete_marked, {%modes}, -1]; | |||||||||||||||||||||||||||
| 271 | }, | ||||||||||||||||||||||||||||
| 272 | 0 | ▶ | 'delete-after' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 273 | 0 | push @{$cur_pipeline}, ['delete-after', \&do_delete_marked, {%modes}, 1]; | |||||||||||||||||||||||||||
| 274 | }, | ||||||||||||||||||||||||||||
| 275 | 0 | ▶ | 'delete-at-offset=i' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 276 | 0 | push @{$cur_pipeline}, ['delete-at-offset', \&do_delete_marked, {%modes}, $_[1]]; | |||||||||||||||||||||||||||
| 277 | }, | ||||||||||||||||||||||||||||
| 278 | 0 | ▶ | 'insert-before=s' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 279 | 0 | push @{$cur_pipeline}, ['insert-before', \&do_insert_marked, {%modes}, -1, $_[1]]; | |||||||||||||||||||||||||||
| 280 | }, | ||||||||||||||||||||||||||||
| 281 | 0 | ▶ | 'insert-after=s' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 282 | 0 | push @{$cur_pipeline}, ['insert-after', \&do_insert_marked, {%modes}, 0, $_[1]]; | |||||||||||||||||||||||||||
| 283 | }, | ||||||||||||||||||||||||||||
| 284 | 0 | ▶ | 'insert-at-offset=s{2}' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 285 | 0 | push @{$cur_pipeline}, ['insert-at-offset', \&do_insert_marked, {%modes}, $_[1]]; | |||||||||||||||||||||||||||
| 286 | }, | ||||||||||||||||||||||||||||
| 287 | 'clear-markers' => | ||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub { push @{$cur_pipeline}, ['clear-markers', \&do_set_markers, {%modes}, 0] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 289 | 0 | ▶ | 'set-all-markers' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 290 | 0 | push @{$cur_pipeline}, ['set-all-markers', \&do_set_markers, {%modes}, 1]; | |||||||||||||||||||||||||||
| 291 | }, | ||||||||||||||||||||||||||||
| 292 | 0 | ▶ | 'cut=s' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 293 | 0 | push @{$cur_pipeline}, ['cut', \&do_cut, {%modes}, validate_cut_spec($_[1])]; | |||||||||||||||||||||||||||
| 294 | }, | ||||||||||||||||||||||||||||
| 295 | 0 | ▶ | 'paste=s' => sub { push @{$cur_pipeline}, ['paste', \&do_paste, {%modes}, $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 296 | 0 | ▶ | 'pivot' => sub { push @{$cur_pipeline}, ['pivot', \&do_pivot, {%modes}, 'pivot'] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 297 | 0 | ▶ | 'anti-pivot' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 298 | 0 | push @{$cur_pipeline}, ['anti-pivot', \&do_pivot, {%modes}, 'anti-pivot']; | |||||||||||||||||||||||||||
| 299 | }, | ||||||||||||||||||||||||||||
| 300 | 0 | ▶ | 'transpose' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 301 | 0 | push @{$cur_pipeline}, ['transpose', \&do_pivot, {%modes}, 'transpose']; | |||||||||||||||||||||||||||
| 302 | }, | ||||||||||||||||||||||||||||
| 303 | 'number-lines|nl' => | ||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub { push @{$cur_pipeline}, ['number-lines', \&do_number_lines, {%modes}] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 305 | 0 | ▶ | 'file-name|fn' => sub { push @{$cur_pipeline}, ['file-name', \&do_file_name, {%modes}, 1] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 306 | 'prefix-file-name|pfn' => | ||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub { push @{$cur_pipeline}, ['prefix-file-name', \&do_file_name, {%modes}, 0] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 308 | 0 | ▶ | 'line-count|lc' => sub { push @{$cur_pipeline}, ['line-count', \&do_line_count, {%modes}] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | 'tee=s' => sub { push @{$cur_pipeline}, ['tee', \&do_tee, {%modes}, $_[1]] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 310 | 0 | ▶ | 'shell=s' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 311 | 0 | push @{$cur_pipeline}, ['shell', \&do_shell, {%modes}, 'shell', $_[1]]; | |||||||||||||||||||||||||||
| 312 | }, | ||||||||||||||||||||||||||||
| 313 | 0 | ▶ | 'xargs=s' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 314 | 0 | push @{$cur_pipeline}, ['xargs', \&do_shell, {%modes}, 'xargs', $_[1]]; | |||||||||||||||||||||||||||
| 315 | }, | ||||||||||||||||||||||||||||
| 316 | 0 | ▶ | 'push' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 317 | 0 | push @{$cur_pipeline}, ['push', \&do_push, {%modes}, 'push']; | |||||||||||||||||||||||||||
| 318 | }, | ||||||||||||||||||||||||||||
| 319 | 0 | ▶ | 'pop' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 320 | 0 | push @{$cur_pipeline}, ['pop', \&do_push, {%modes}, 'pop']; | |||||||||||||||||||||||||||
| 321 | },) | ||||||||||||||||||||||||||||
| 322 | 1 | } | |||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | 1 | ▶ | sub all_args { | ||||||||||||||||||||||||||
|
Subroutine
all_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 325 | 1 | return (options_flags(), modes_flags(), input_flags(), action_flags()); | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | # Because of the way the options are processed, each --replace options | ||||||||||||||||||||||||||||
| 329 | # (expecting two arguments) is pushed twice in the pipeline sub (once for each | ||||||||||||||||||||||||||||
| 330 | # argument). We're fixing this here. | ||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub fix_pipeline { | ||||||||||||||||||||||||||
|
Subroutine
fix_pipeline: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 332 | 0 | my ($pipeline) = @_; | |||||||||||||||||||||||||||
| 333 | 0 | for my $i (0 .. $#{$pipeline}) { | |||||||||||||||||||||||||||
| 334 | 0 | ▶ | if ($pipeline->[$i][0] eq 'substitute') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 335 | 0 | push @{$pipeline->[$i]}, $pipeline->[$i + 1]->[3]; | |||||||||||||||||||||||||||
| 336 | 0 | $pipeline->[$i + 1][0] = 'garbage'; | |||||||||||||||||||||||||||
| 337 | } elsif ($pipeline->[$i][0] eq 'insert-at-offset') { | ||||||||||||||||||||||||||||
| 338 | 0 | my $o = $pipeline->[$i]->[3]; | |||||||||||||||||||||||||||
| 339 | 0 | ▶ | if (!ist_int($o)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 340 | 0 | die "The first argument to --insert-at-offset must be an integer: $o\n"; | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | 0 | push @{$pipeline->[$i]}, $pipeline->[$i + 1]->[3]; | |||||||||||||||||||||||||||
| 343 | 0 | $pipeline->[$i + 1][0] = 'garbage'; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | 0 | @{$pipeline} = grep { $_->[0] ne 'garbage' } @{$pipeline}; | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | # parse_command_line(\@args) | ||||||||||||||||||||||||||||
| 350 | 0 | ▶ | sub parse_command_line { | ||||||||||||||||||||||||||
|
Subroutine
parse_command_line: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 351 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||
| 352 | 0 | reset_global(); | |||||||||||||||||||||||||||
| 353 | 0 | ▶ | GetOptionsFromArray($args, all_args()) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | or pod2usage(-exitval => 2, -verbose => 0); | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ($options{debug_mode} > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 357 | # When -d is specified multiple times, we add the marker on the final | ||||||||||||||||||||||||||||
| 358 | # output. | ||||||||||||||||||||||||||||
| 359 | 0 | push @{$cur_pipeline}, | |||||||||||||||||||||||||||
| 360 | ['show-marker', \&do_perl, {%modes}, 'perl', 'pf "%s %s", ($m ? "*" : " "), $_']; | ||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 0 | fix_pipeline(\@pre_merge_pipeline); | |||||||||||||||||||||||||||
| 364 | 0 | fix_pipeline(\@post_merge_pipeline); | |||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | # Add any options that were passed after a '--' to the list of inputs. | ||||||||||||||||||||||||||||
| 367 | 0 | push @inputs, @$args; | |||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | # Add the standard input marker to the inputs if no other input were | ||||||||||||||||||||||||||||
| 370 | # specified. | ||||||||||||||||||||||||||||
| 371 | 0 | ▶ | push @inputs, \$App::PTP::Files::stdin_marker if not @inputs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 0 | ▶ | if ($options{in_place} && $options{merge}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options{"in_place"} and $options{"merge"}
MC/DC0%0/2
$options{"in_place"} and $options{"merge"}
$options{"in_place"}
$options{"merge"}
Truth table0%0/3
A and B
A= $options{"in_place"}B= $options{"merge"}
| |||||||||||||||||||||||||||||
| 374 | 0 | die "The --in-place and --merge options are incompatible.\n"; | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 0 | ▶ | if ($options{in_place} && $options{output}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options{"in_place"} and $options{"output"}
MC/DC0%0/2
$options{"in_place"} and $options{"output"}
$options{"in_place"}
$options{"output"}
Truth table0%0/3
A and B
A= $options{"in_place"}B= $options{"output"}
| |||||||||||||||||||||||||||||
| 378 | 0 | ▶ | if ($options{append}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 379 | 0 | die "The --in-place and --append options are incompatible.\n"; | |||||||||||||||||||||||||||
| 380 | } else { | ||||||||||||||||||||||||||||
| 381 | 0 | die "The --in-place and --output options are incompatible.\n"; | |||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if (defined $options{input_filter} && !$options{recursive}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $options{"input_filter"} and not $options{"recursive"}
MC/DC0%0/2
defined $options{"input_filter"} and not $options{"recursive"}
defined $options{"input_filter"}
not $options{"recursive"}
Truth table0%0/3
A and not(B)
A= defined $options{"input_filter"}B= not $options{"recursive"}
| |||||||||||||||||||||||||||||
| 386 | 0 | print "WARNING: The --input-filter option is useless unless --recursive is specified too.\n"; | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 0 | return (\@inputs, \@pre_merge_pipeline, \@post_merge_pipeline, \%options); | |||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 2 | 1; | |||||||||||||||||||||||||||