NAME

Getopt::Pad::Type - option type base class and registry

DESCRIPTION

Abstract base class for option types and home of the type Registry. Subclass it, provide a NAMES constant and glSuffix, optionally check/coerce/label/constraintNotes and SPEC_KEYS, then call Getopt::Pad::Type::registerType with your class. Getopt::Pad::Type::takeFromSpec($spec, $defaultName, $owner) is how an option or arg spec gets its type: it resolves the spec's type name (or the default), takes that name and the type's SPEC_KEYS out of the spec hash, lets the type check those keys through the class method checkSpecKeys (a problem is reported as a spec error for $owner, e.g. "option 'retries'"), and returns the constructed type with the name it answered to, so the SPEC_KEYS handshake lives here and nowhere else.

completes names the shell's own completion a value of the type gets when the user presses tab (files, dirs or undef); the path types use it. glSuffix is the Getopt::Long option-spec suffix the type contributes ('' plain flag, '!' negatable, '+' counter, '=s' takes a value); value-taking types return '=s' even for numbers and validate in check() so all errors speak with one voice. It is the only place Getopt::Long spelling enters a type: the base class derives takesValue and negatable from it and assembles the full option specification in glSpec, so overriding those is rarely useful. The full contract with a worked example is documented under "EXTENDING" in Getopt::Pad.

The small built-in types live in this file: Flag (flag) and its subclass Bool (!) accept only JSON or YAML booleans, 1, 0 and '' and store 1 or 0; Counter (+) accepts only non-negative integers; String (s) accepts any single value. The built-ins with more behaviour (Int, Float, File, Dir, Url) have modules of their own.

Part of the Getopt::Pad distribution; see its documentation for the user-facing API.

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.