NAME

MYDan::Util::OptConf - Get command line options.

SYNOPSIS

use MYDan::Util::OptConf;

$MYDan::Util::OptConf::ARGC = -1;
@MYDan::Util::OptConf::CONF = qw( pass_through );

my $option = MYDan::Util::OptConf->load( conf => '/conf/file' );

my $option = MYDan::Util::OptConf->load( base => '/conf/path' );

my %foo = $option->dump( 'foo' );

my %opt = $option->set( bar => 'baz' )->get( 'timeout=i', 'verbose' )->dump;

METHODS

load( $conf )

Load options from a YAML file $conf, which if unspecified, defaults to $RealBin/.config, or $RealBin/../.config, if either exists. Returns object.

dump( $name )

Dump options by $name, or that of $0 if $name is unspecified. Returns HASH in scalar context or flattened HASH in list context.

set( %opt )

Set options specified by %opt for $0. Returns object.

get( @option )

Invoke Getopt::Long to get @option, if any specified. Returns object.

Getopt::Long is configured through @CONF.

The leftover @ARGV size is asserted through $ARGC. @ARGV cannot be empty if $ARGC is negative, otherwise size of @ARGV needs to equal $ARGC.

assert( @option )

print help and exit, if any of @option is not defined.

macro( $path )

Replace $ROOT in $path if defined.