blib/lib/Getopt/Kingpin/Type/ExistingFileOrDir.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 21 | 21 | 100.0 |
branch | 2 | 2 | 100.0 |
condition | n/a | ||
subroutine | 6 | 6 | 100.0 |
pod | 1 | 1 | 100.0 |
total | 30 | 30 | 100.0 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Getopt::Kingpin::Type::ExistingFileOrDir; | ||||||
2 | 1 | 1 | 20 | use 5.008001; | |||
1 | 4 | ||||||
3 | 1 | 1 | 5 | use strict; | |||
1 | 2 | ||||||
1 | 23 | ||||||
4 | 1 | 1 | 5 | use warnings; | |||
1 | 2 | ||||||
1 | 30 | ||||||
5 | 1 | 1 | 5 | use Carp; | |||
1 | 2 | ||||||
1 | 74 | ||||||
6 | 1 | 1 | 7 | use Path::Tiny; | |||
1 | 1 | ||||||
1 | 170 | ||||||
7 | |||||||
8 | our $VERSION = "0.09"; | ||||||
9 | |||||||
10 | sub set_value { | ||||||
11 | 3 | 3 | 1 | 6 | my $self = shift; | ||
12 | 3 | 15 | my ($value) = @_; | ||||
13 | |||||||
14 | 3 | 14 | my $p = path($value); | ||||
15 | 3 | 100 | 143 | if ($p->exists) { | |||
16 | # ok | ||||||
17 | } else { | ||||||
18 | 1 | 109 | printf STDERR "error: path '%s' does not exist, try --help\n", $value; | ||||
19 | 1 | 11 | return undef, 1; | ||||
20 | } | ||||||
21 | 2 | 88 | return $p; | ||||
22 | } | ||||||
23 | |||||||
24 | 1; | ||||||
25 | __END__ |