NAME

Getopt::Pad::Spec - The checked spec of one GetOptions call (internal)

DESCRIPTION

This module is internal to Getopt::Pad. It is not part of the public API and can change without notice. Programs use "GetOptions" in Getopt::Pad; this page is for people working on Getopt::Pad itself.

Getopt::Pad::Spec turns the arguments of GetOptions into a tree of checked objects before any command line is looked at. Everything after its construction works with these objects, never with the raw hashes.

Constructing a spec (Getopt::Pad::Spec->new(raw => \%spec)):

  1. takes the config key out and builds a Getopt::Pad::Spec::Config from it, and takes the version key out;

  2. builds the top level as a Getopt::Pad::Spec::Level, which builds its options, args and commands recursively;

  3. attaches the automatic options: --help to every level, --version and --create-completions to the top level, and with a config block --config and --create-default-config to the top level, marked as inherited;

  4. passes every inherited option down to all levels below the level that declares it;

  5. with a config block, refuses a group named commands on a level with commands, because config files use that key for the command sections.

This module owns the one table of automatic options. Each entry names where the option is attached, its option spec, and its trigger: the code the parser runs when the command line sets the option. Every trigger ends the parse by throwing a Getopt::Pad::ExitRequest that carries the finished output, so no other module needs to know what an automatic option does. --config has no trigger; the parser uses its value to load config files.

METHODS

root

The top level, a Getopt::Pad::Spec::Level.

config

The Getopt::Pad::Spec::Config, or undef without a config block.

version

The version key of the spec, or undef.

helperFor($level, %overrides)

A Getopt::Pad::Help for $level. The only place help renderers are created. %overrides are passed to its constructor, for example handle => \*STDERR.

CONFIG_OPTION

The name of the automatic --config option.

SEE ALSO

Getopt::Pad::Spec::Level, Getopt::Pad::Parser

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.