File Coverage

blib/lib/App/supertouch.pm
Criterion Covered Total %
statement 26 36 72.2
branch 7 18 38.8
condition 1 3 33.3
subroutine 5 5 100.0
pod 0 1 0.0
total 39 63 61.9


line stmt bran cond sub pod time code
1             package App::supertouch;
2              
3 1     1   199621 use strict;
  1         5  
  1         24  
4 1     1   5 use warnings;
  1         1  
  1         19  
5 1     1   21 use 5.008001;
  1         3  
6 1     1   672 use Path::Tiny qw( path );
  1         10062  
  1         343  
7              
8             # ABSTRACT: Touch with directories
9             our $VERSION = '0.01'; # VERSION
10              
11              
12             sub main
13             {
14 2     2 0 8534 my(undef, @args) = @_;
15              
16 2         4 my $verbose = 0;
17 2         3 my $options = 1;
18              
19 2         4 foreach my $arg (@args)
20             {
21 2 50 33     12 if($options && $arg =~ /^-/)
22             {
23 0 0       0 if($arg eq '--')
    0          
24             {
25 0         0 $options = 0;
26             }
27             elsif($arg eq '-v')
28             {
29 0         0 $verbose = 1;
30             }
31 0         0 next;
32             }
33 2 50       5 if($arg eq '')
34             {
35 0         0 print STDERR "'' (empty) is not a legal filename";
36 0         0 return 2;
37             }
38 2         5 my $file = path($arg);
39 2 50       47 if($file->is_dir)
40             {
41 0         0 print STDERR "$file is a directory";
42 0         0 return 2;
43             }
44 2 50       52 unless(-d $file->parent)
45             {
46 2 50       151 print "DIR @{[ $file->parent ]}\n" if $verbose;
  0         0  
47 2         6 $file->parent->mkpath;
48             }
49 2 50       518 unless(-f $file)
50             {
51 2 50       41 print "FILE @{[ $file ]}\n" if $verbose;
  0         0  
52 2         9 $file->touch;
53             }
54             }
55              
56 2         354 return 0;
57             }
58              
59             1;
60              
61             __END__