Elliot Shank > MooseX-Getopt-Defanged-v1.18.0 > MooseX::Getopt::Defanged::OptionTypeMetadata

Download:
MooseX-Getopt-Defanged-v1.18.0.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Module Version: v1.18.0   Source  

NAME ^

MooseX::Getopt::Defanged::OptionTypeMetadata - Bookkeeping of option type metadata MooseX::Getopt::Defanged.

SYNOPSIS ^

    package Some::Program;

    use Moose;

    with qw< MooseX::Getopt::Defanged >;


    sub run {
        my ($self, $argv_ref) = @_;

        $self->_configure($argv_ref);

        ...
    } # end run()


    sub _configure {
        my ($self, $argv_ref) = @_;

        my $metadata = $self->get_option_type_metadata();
        $metadata->set_default_specification(Bool   => '!');
        $metadata->set_default_specification(Int    => '=o');
        $metadata->set_default_specification(Str    => ':s');
        $metadata->set_default_specification(MyType => '=s{2,3}');

        $metadata->set_default_value_generator(Int => sub { 5 });

        $self->parse_command_line($argv_ref);

        ...

        return;
    } # end _configure()

VERSION ^

This document describes MooseX::Getopt::Defanged::OptionTypeMetadata version 1.18.0.

DESCRIPTION ^

This is a holder of metadata about Moose types for MooseX::Getopt::Defanged. For example, it keeps track of what the default Getopt::Long specification should be for a given type.

This contains default mappings for the following types:

    Type                   Specification
    -------------          -------------
    Bool                   «empty»
    Str                    =s
    Int                    =i
    Num                    =f
    RegexpRef              =s
    ArrayRef               =s{1,}
    ArrayRef[Str]          =s{1,}
    ArrayRef[Int]          =i{1,}
    ArrayRef[Num]          =f{1,}
    HashRef                =s%
    HashRef[Str]           =s%
    HashRef[Int]           =i%
    HashRef[Num]           =f%

Also, for each type, "Maybe[«type»]" uses the same specification.

INTERFACE ^

get_default_specification($type)

Given a type name, returns the default Getopt::Long specification for the type, if there is one.

set_default_specification($type => $specification)

Sets the default Getopt::Long specification for options of the given type. Use this to override the defaults or to specify a default for a type you created via Moose's subtype mechanism.

delete_default_specification($type)

Removes any default specification for the given type (because the empty string is a valid specification).

get_default_value_generator($type)

Given a type name, returns a code reference that can provide a default value for an option of the given type, if there is one.

set_default_value_generator( $type => sub { ... } )

Sets the generator of default values for options of the given type. The subroutine will get no arguments. Use this to override the defaults or to specify a default for a type you created via Moose's subtype mechanism.

get_default_stringifier($type)

Given a type name, returns a code reference that can convert from an option of the given type to a string, if there is one.

set_default_stringifier( $type => sub { ... } )

Sets the to-string converter for options of the given type. The subroutine will get a single argument of the value to convert to a string. Use this to override the defaults or to specify a default for a type you created if you don't want to use Perl's standard stringification or overload.

get_default_destringifier($type)

Given a type name, returns a code reference that can convert from a string to the value an option of the given type, if there is one.

set_default_destringifier( $type => sub { ... } )

Sets the from-string converter for options of the given type. The subroutine will get a single argument of the string to be turned into the option value. Use this to override the defaults or to specify a default for a type you created if you don't want to use Moose's subtype mechanism.

DIAGNOSTICS ^

If you specify an attribute type that this class doesn't understand, a MooseX::Getopt::Defanged::Exception::InvalidSpecification will be thrown with the message There's no "$type_name" type..

CONFIGURATION AND ENVIRONMENT ^

See MooseX::Getopt::Defanged.

DEPENDENCIES ^

perl 5.10

Moose

Moose::Util::TypeConstraints

MooseX::Accessors::ReadWritePrivate

MooseX::AttributeHelpers

MooseX::StrictConstructor

AUTHOR ^

Elliot Shank <perl@galumph.com>

LICENSE AND COPYRIGHT ^

Copyright ©2008-2010, Elliot Shank

DISCLAIMER OF WARRANTY ^

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

syntax highlighting: