File Coverage

blib/lib/App/FileTestUtils.pm
Criterion Covered Total %
statement 9 27 33.3
branch 0 12 0.0
condition 0 4 0.0
subroutine 3 4 75.0
pod 0 1 0.0
total 12 48 25.0


line stmt bran cond sub pod time code
1             package App::FileTestUtils;
2              
3 1     1   267004 use strict 'subs', 'vars';
  1         3  
  1         47  
4 1     1   5 use warnings;
  1         2  
  1         112  
5              
6             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
7             our $DATE = '2023-11-30'; # DATE
8             our $DIST = 'App-FileTestUtils'; # DIST
9             our $VERSION = '0.005'; # VERSION
10              
11 1     1   705 use Getopt::Long qw(:config auto_help auto_version gnu_getopt no_ignore_case);
  1         10949  
  1         4  
12              
13             sub do_script {
14 0     0 0   require File::Util::Test;
15 0           my ($func) = @_;
16              
17 0           (my $script = $func) =~ s/_/-/g;
18              
19 0           my $opt_grep_mode;
20             my $opt_invert_match;
21 0 0         GetOptions(
22             "grep-mode|g" => \$opt_grep_mode,
23             "invert-match|v" => \$opt_invert_match,
24             ) or die "$script: Error in processing command-line options, exiting\n";
25              
26 0 0         if ($opt_grep_mode) {
27 0           my @files = @ARGV;
28 0 0         unless (@files) { chomp(@files = ) }
  0            
29 0           for my $file (@files) {
30 0 0 0       if (&{"File::Util::Test::$func"}($file) xor $opt_invert_match) { print $file, "\n" }
  0            
  0            
31             }
32 0           exit 0;
33             } else {
34 0 0         unless (@ARGV == 1) {
35 0           die "Usage: $script \n";
36             }
37 0 0         exit(&{"File::Util::Test::$func"}($ARGV[0]) ? 0:1);
  0            
38             }
39             }
40              
41             1;
42             # ABSTRACT: More CLIs for file testing
43              
44             __END__