File Coverage

blib/lib/App/cdif/Command.pm
Criterion Covered Total %
statement 11 33 33.3
branch 0 14 0.0
condition 0 2 0.0
subroutine 4 8 50.0
pod 4 4 100.0
total 19 61 31.1


line stmt bran cond sub pod time code
1             package App::cdif::Command;
2              
3 10     10   6637 use v5.14;
  10         39  
4 10     10   71 use warnings;
  10         20  
  10         576  
5 10     10   1333 use utf8;
  10         411  
  10         99  
6              
7 10     10   418 use parent 'Command::Run';
  10         19  
  10         78  
8              
9             # Compatibility: expand array reference in command
10             sub command {
11 0     0 1   my $obj = shift;
12 0 0         if (@_) {
13 0 0         my @cmd = map { ref eq 'ARRAY' ? @$_ : $_ } @_;
  0            
14 0           return $obj->SUPER::command(@cmd);
15             }
16 0           $obj->SUPER::command;
17             }
18              
19             # Compatibility wrapper for read_error option
20             sub option {
21 0     0 1   my $obj = shift;
22 0 0         if (@_ == 1) {
23 0           my $key = shift;
24 0 0         if ($key eq 'read_error') {
25 0   0       my $stderr = $obj->SUPER::option('stderr') // '';
26 0 0         return $stderr eq 'redirect' ? 1 : 0;
27             }
28 0           return $obj->SUPER::option($key);
29             } else {
30 0           while (my($k, $v) = splice @_, 0, 2) {
31 0 0         if ($k eq 'read_error') {
32 0 0         $obj->SUPER::option(stderr => $v ? 'redirect' : undef);
33             } else {
34 0           $obj->SUPER::option($k => $v);
35             }
36             }
37 0           return $obj;
38             }
39             }
40              
41             # Compatibility: return INPUT filehandle
42             sub stdin {
43 0     0 1   my $obj = shift;
44 0           $obj->{INPUT};
45             }
46              
47             # Compatibility: setstdin method
48             sub setstdin {
49 0     0 1   my $obj = shift;
50 0           $obj->with(stdin => shift);
51             }
52              
53             1;
54              
55             __END__