NAME
Getopt::Pad::Spec::Level - One level of a spec: the top level or one command (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.
A level holds its options and either its args or its commands. It is built from the hash of one level of the spec and checks everything that concerns the level as a whole:
every name and alias is used by only one option of the level, including the options it inherits from outer levels and the automatic options;
no two options or args map to the same reader;
only the last arg has
multiple, and no required arg follows an optional one;a level has args or commands, not both;
only a level with commands marks options
inherit, and only such a level hascommandRequired;command names are valid names,
examplesare well formed, and there are no unknown keys.
Commands are built recursively as levels of their own, each with its command path.
METHODS
- path
-
The command path of the level, such as
image resize; the empty string for the top level. - isRoot, label, where
-
Whether this is the top level; its name in messages (
the top levelorcommand 'PATH'); and the prefix of spec errors about it (empty for the top level,command 'PATH':otherwise). - options
-
Every option the level's command line accepts: its own options, the automatic options attached to it, and the options it inherits.
- declaredOptions
-
Only the level's own options from the spec, without automatic and inherited options. These are the options with readers.
- inheritableOptions, inheritedOptions
-
The level's own options that are passed on to the levels below, and the options it received from the levels above.
- optionByName($name)
-
One of the level's own options, by primary name, or
undef. Inherited options are not found here. - args, hasArgs
-
The arg specs in order, and whether there are any.
- commandNames, command($name), hasCommands, commandRequired
-
The sorted command names, the level of one command, whether there are commands, and whether one must be named.
- description, examples
-
As given in the spec.
- addOption($option), inheritOption($option, $fromLevel)
-
Used while the spec is built: add an own or automatic option, or an option inherited from
$fromLevel. Both reserve the option's names on this level.
SEE ALSO
Getopt::Pad::Spec, Getopt::Pad::Spec::Option, Getopt::Pad::Spec::Arg
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.