Work in progress on the github site. C.f.
https://github.com/dagolden/getopt-lucid/commit/dc181f7f5e687be4aa8e0a4f1176a19d5d59b30c
From new POD:
Options object validation
The "validate" method should be called on the result of "getopt".
This
will check that all parameter prerequisites defined by "needs" have
been met. It also takes a hashref of arguments. The optional
"requires" argument gives an arrayref of parameters that must exist.
The reason that object validation is done separate from "getopt"
is to
allow for better control over different options that might be
required
or to allow some dependencies (i.e. from "needs") to be met via a
configuration file.
@spec = (
Param("action")->needs(qw/user password/),
Param("user"),
Param("password"),
);
$opt = Getopt::Lucid->getopt(\@spec);
$opt->merge_defaults( read_config() ); # provides 'user' &
'password'
$opt->validate({requires => ['action']});
Thoughts about this approach welcome. (I still hope to add some better
sugar for "help" options, too.)