2 package MooseX::Getopt::Meta::Attribute::Trait;
4 use Moose::Util::TypeConstraints;
7 our $AUTHORITY = 'cpan:STEVAN';
12 predicate => 'has_cmd_flag',
15 # This subtype is to support scalar -> arrayref coercion
16 # without polluting the built-in types
17 subtype '_MooseX_Getopt_CmdAliases' => as 'ArrayRef';
19 coerce '_MooseX_Getopt_CmdAliases'
23 has 'cmd_aliases' => (
25 isa => '_MooseX_Getopt_CmdAliases',
26 predicate => 'has_cmd_aliases',
32 # register this as a metaclass alias ...
33 package # stop confusing PAUSE
34 Moose::Meta::Attribute::Custom::Trait::Getopt;
35 sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait' }
45 MooseX::Getopt::Meta::Attribute::Trait - Optional meta attribute trait for custom option names
52 with 'MooseX::Getopt';
55 traits => [ 'Getopt' ],
58 default => 'file.dat',
60 # tells MooseX::Getopt to use --somedata as the
61 # command line flag instead of the normal
62 # autogenerated one (--data)
63 cmd_flag => 'somedata',
65 # tells MooseX::Getopt to also allow --moosedata,
66 # -m, and -d as aliases for this same option on
68 cmd_aliases => [qw/ moosedata m d /],
70 # Or, you can use a plain scalar for a single alias:
76 This is a custom attribute metaclass trait which can be used to
77 specify a the specific command line flag to use instead of the
78 default one which L<MooseX::Getopt> will create for you.
82 These methods are of little use to most users, they are used interally
83 within L<MooseX::Getopt>.
89 Changes the commandline flag to be this value, instead of the default,
90 which is the same as the attribute name.
94 Adds more aliases for this commandline flag, useful for short options
99 =item B<has_cmd_aliases>
107 All complex software has bugs lurking in it, and this module is no
108 exception. If you find a bug please either email me, or add the bug
113 Stevan Little E<lt>stevan@iinteractive.comE<gt>
115 =head1 COPYRIGHT AND LICENSE
117 Copyright 2007-2008 by Infinity Interactive, Inc.
119 L<http://www.iinteractive.com>
121 This library is free software; you can redistribute it and/or modify
122 it under the same terms as Perl itself.