Config::Maker::Type - describe directive type
use Config::Maker my $type = Config::Maker::Type->new( name => $name, format => [$typespec => @valuespec], children => \@children, contexts => \@parents, checks => [$check => $path, ...], actions => \@actions ) $type->add($othertype); $othertype->addto($type); $type->addchecks(@checks)
Config::Maker::Type describe available types of options (and metaconfig options). Each type has 5 parameters. These are:
The name of the directive. This is the keyword used in config to specify option of this type.
This is a listref, that is passed to the body production in Config::Maker::Grammar. The first element is either simple, named_group or anon_group, to mean option without block, option with value and block and option with only a block respectively. For the first two, rest of the list is passed to the value production of the grammar.
body
simple
named_group
anon_group
value
This is a list of types, that should be recognized in the body of this type. Parser won't recognize other types when parsing body of this type.
This is a list of keyword-path pairs, that specify how many of different subtypes can appear in an option of this type. The keys may be none, opt, one, mand or any, which mean the following path must have no, at most one, exactly one, at least one and any number of matches respectively. An error is reported when those conditions are not met.
none
opt
one
mand
any
This is a list of perl closures, that shall be invoked when option of this type is parsed. It can do whatever it wants.
The constructor takes these five named arguments and one extra, contexts. The new element is added to those types as a child.
contexts
In addition to constructor, there are three methods, add, addto and addchecks. These allow to add children, parents and checks to an already constructed type.
add
addto
addchecks
For description how types are constructed from the schema in metaconfig see configit(1).
There are two special types, / and *, accessible through class methods root and repository.
/
*
root
repository
The / special type represents the top-level of a config or metaconfig file. On top-level, only option types added to this special type are recognized.
The * special type is a repository of types. It is used in schema to store types for reuse.
Jan Hudec <bulb@ucw.cz>
Copyright 2004 Jan Hudec. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
configit(1), perl(1), Config::Maker(3pm).
To install Config::Maker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Maker
CPAN shell
perl -MCPAN -e shell install Config::Maker
For more information on module installation, please visit the detailed CPAN module installation guide.