prettty much done I think
[gitmo/MooseX-Getopt.git] / lib / MooseX / Getopt / OptionTypeMap.pm
CommitLineData
8034a232 1
2package MooseX::Getopt::OptionTypeMap;
3
4use Moose 'confess';
5use Moose::Util::TypeConstraints 'find_type_constraint';
6
7our $VERSION = '0.01';
8our $AUTHORITY = 'cpan:STEVAN';
9
10my %option_type_map = (
11 'Bool' => '!',
12 'Str' => '=s',
13 'Int' => '=i',
14 'Float' => '=f',
15 'ArrayRef' => '=s@',
16 'HashRef' => '=s%',
17);
18
19sub has_option_type { exists $option_type_map{$_[1]} }
20sub get_option_type { $option_type_map{$_[1]} }
21sub add_option_type_to_map {
22 my (undef, $type_name, $option_string) = @_;
23 (defined $type_name && defined $option_string)
24 || confess "You must supply both a type name and an option string";
25 (find_type_constraint($type_name))
26 || confess "The type constraint '$type_name' does not exist";
27 $option_type_map{$type_name} = $option_string;
28}
29
30no Moose; no Moose::Util::TypeConstraints; 1;
31
32__END__
33
34
35=pod
36
37=head1 NAME
38
39MooseX::Getopt::OptionTypeMap - Storage for the option to type mappings
40
41=head1 DESCRIPTION
42
43See the I<Custom Type Constraints> section in the L<MooseX::Getopt> docs
44for more info about how to use this module.
45
46=head1 METHODS
47
48These are all class methods and should be called as such.
49
50=over 4
51
52=item B<has_option_type ($type_name)>
53
54=item B<get_option_type ($type_name)>
55
56=item B<add_option_type_to_map ($type_name, $option_spec)>
57
58=back
59
60=head1 BUGS
61
62All complex software has bugs lurking in it, and this module is no
63exception. If you find a bug please either email me, or add the bug
64to cpan-RT.
65
66=head1 AUTHOR
67
68Stevan Little E<lt>stevan@iinteractive.comE<gt>
69
70=head1 COPYRIGHT AND LICENSE
71
72Copyright 2007 by Infinity Interactive, Inc.
73
74L<http://www.iinteractive.com>
75
76This library is free software; you can redistribute it and/or modify
77it under the same terms as Perl itself.
78
79=cut