2 package MooseX::Getopt::Meta::Attribute::Trait;
4 use Moose::Util::TypeConstraints;
6 our $VERSION = '0.150001';
7 our $AUTHORITY = 'cpan:STEVAN';
12 predicate => 'has_cmd_name',
15 # TODO: should be removed - it loses Getopt abstraction
19 predicate => 'has_cmd_flag',
25 predicate => 'has_cmd_type',
28 # This subtype is to support scalar -> arrayref coercion
29 # without polluting the built-in types
30 subtype '_MooseX_Getopt_CmdAliases' => as 'ArrayRef';
32 coerce '_MooseX_Getopt_CmdAliases'
36 has 'cmd_aliases' => (
38 isa => '_MooseX_Getopt_CmdAliases',
39 predicate => 'has_cmd_aliases',
45 # register this as a metaclass alias ...
46 package # stop confusing PAUSE
47 Moose::Meta::Attribute::Custom::Trait::Getopt;
48 sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait' }
58 MooseX::Getopt::Meta::Attribute::Trait - Optional meta attribute trait for custom option names
65 with 'MooseX::Getopt';
68 traits => [ 'Getopt' ],
71 default => 'file.dat',
73 # tells MooseX::Getopt to use --somedata as the
74 # command line flag instead of the normal
75 # autogenerated one (--data)
76 cmd_flag => 'somedata',
78 # tells MooseX::Getopt to also allow --moosedata,
79 # -m, and -d as aliases for this same option on
81 cmd_aliases => [qw/ moosedata m d /],
83 # Or, you can use a plain scalar for a single alias:
89 This is a custom attribute metaclass trait which can be used to
90 specify a the specific command line flag to use instead of the
91 default one which L<MooseX::Getopt> will create for you.
95 These methods are of little use to most users, they are used interally
96 within L<MooseX::Getopt>.
102 Changes the commandline flag to be this value, instead of the default,
103 which is the same as the attribute name.
107 Adds more aliases for this commandline flag, useful for short options
110 =item B<has_cmd_flag>
112 =item B<has_cmd_aliases>
120 All complex software has bugs lurking in it, and this module is no
121 exception. If you find a bug please either email me, or add the bug
126 Stevan Little E<lt>stevan@iinteractive.comE<gt>
128 =head1 COPYRIGHT AND LICENSE
130 Copyright 2007-2008 by Infinity Interactive, Inc.
132 L<http://www.iinteractive.com>
134 This library is free software; you can redistribute it and/or modify
135 it under the same terms as Perl itself.