| 1 | 23 | ▶ | use v5.26; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 23 | ▶ | use Object::Pad; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 23 | ▶ | use Getopt::Pad::Type::Path; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | class Getopt::Pad::Type::File :isa(Getopt::Pad::Type::Path) :strict(params) { | ||||||||||
| 7 | 23 | ▶ | use constant NAMES => ['file']; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 23 | ▶ | use File::Basename (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 23 | ▶ | use File::Path (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 23 | our $VERSION = '0.06'; | |||||||||
| 12 | |||||||||||
| 13 | 2 | ▶ | method label() { return 'File Path' } | ||||||||
|
Subroutine
label: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | |||||||||||
| 15 | 7 | ▶ | method kind() { return 'file' } | ||||||||
|
Subroutine
kind: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 16 | |||||||||||
| 17 | 1 | ▶ | method completes() { return 'files' } | ||||||||
|
Subroutine
completes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 18 | |||||||||||
| 19 | 12 | ▶ | method pathExists($value) { return -f $value } | ||||||||
|
Subroutine
pathExists: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 20 | |||||||||||
| 21 | # The parent directories are created along with the empty file. | ||||||||||
| 22 | 3 | ▶ | method createPath($value) { | ||||||||
|
Subroutine
createPath: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||
| 23 | 3 | File::Path::make_path(File::Basename::dirname($value), { error => \my $errors }); | |||||||||
| 24 | 3 | ▶ | if ($errors->@*) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | my ($path, $reason) = $errors->[0]->%*; | |||||||||
| 26 | 0 | return $reason; | |||||||||
| 27 | } | ||||||||||
| 28 | 3 | ▶ | open my $handle, '>>', $value or return "$!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 2 | close $handle; | |||||||||
| 30 | 2 | return undef; | |||||||||
| 31 | 23 | } | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 23 | 1; | |||||||||
| 35 | |||||||||||
| 36 | __END__ | ||||||||||