NAME

Getopt::Pad::Type::Path - Base class of the file and dir option types

DESCRIPTION

The common base class of Getopt::Pad::Type::File and Getopt::Pad::Type::Dir. It is abstract: specs cannot use it directly.

It provides the spec keys mustExist and createPathIfMissing, which exclude each other (mustExist and createPathIfMissing are mutually exclusive):

mustExist

The value that is finally used must be an existing path of the subclass's kind, checked in verify (see "verify" in Getopt::Pad::Type), never when the spec is built. A missing path is rejected with KIND 'PATH' does not exist, where KIND is file or directory, and a path of the other kind with 'PATH' is not a KIND. The help output shows [has to exist].

createPathIfMissing

A missing path is created for the value that is finally used (in prepare, see "prepare" in Getopt::Pad::Type). A path of the other kind is rejected in verify with 'PATH' is not a KIND, a failure to create it with cannot create KIND 'PATH': REASON. The help output shows [created if missing].

Both are described for users in "Type-specific keys" in Getopt::Pad. Every path type takes a value (glSuffix '=s').

A subclass provides NAMES and these methods:

kind

The word used for the path in messages: file or directory.

pathExists($path)

Whether $path exists and is of the right kind.

createPath($path)

Creates $path. Returns undef on success, otherwise the reason it failed.

SEE ALSO

Getopt::Pad::Type, Getopt::Pad::Type::File, Getopt::Pad::Type::Dir

AUTHOR

davenonymous <perl@davenonymous.com>

COPYRIGHT AND LICENSE

Copyright 2026 davenonymous

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.