NAME

Getopt::Yath::Option::Map - Base class for 'map' style options.

DESCRIPTION

Expects all values to be key=value pairs and produces a hashref. --opt foo=bar will set $h{foo} = 'bar'. If a split_on parameter is provided then a single use can set multiple values. For example if split_on is set to , then --opt foo=bar,baz=bat is provided, then the result will have $h{foo} = 'bar'; $h{baz} = 'bat'.

SYNOPSIS

option env_var => (
    field          => 'env_vars',
    short          => 'E',
    type           => 'Map',
    long_examples  => [' VAR=VAL'],
    short_examples => ['VAR=VAL', ' VAR=VAL'],
    description    => 'Set environment variables',
);

METHODS

All methods from Getopt::Yath::Option are inherited. The following are overridden or noteworthy:

requires_arg: true
allows_list: true

Each use of --opt key=val adds to the hash. --no-opt empties it.

normalize_value(@input)

If the input looks like a JSON object (e.g., '{"a":"b"}'), it is decoded and the key/value pairs are returned. Otherwise values are split on key_on (default =) to produce key/value pairs. If split_on is set, values are split on that delimiter first.

get_initial_value

Checks from_env_vars. For maps, the environment variable name is used as the key and the variable's value as the hash value. Returns an empty hashref if no environment values are found.

ADDITIONAL ATTRIBUTES

split_on => $delimiter

A string or regex to split values on before extracting key/value pairs.

key_on => $delimiter

The delimiter between keys and values. Defaults to =.

SOURCE

The source code repository for Getopt-Yath can be found at http://github.com/Test-More/Getopt-Yath/.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/