1 package MooseX::Getopt::Meta::Attribute::Trait;
2 # ABSTRACT: Optional meta attribute trait for custom option names
5 use Moose::Util::TypeConstraints;
10 predicate => 'has_cmd_flag',
13 # This subtype is to support scalar -> arrayref coercion
14 # without polluting the built-in types
15 subtype '_MooseX_Getopt_CmdAliases' => as 'ArrayRef';
17 coerce '_MooseX_Getopt_CmdAliases'
21 has 'cmd_aliases' => (
23 isa => '_MooseX_Getopt_CmdAliases',
24 predicate => 'has_cmd_aliases',
28 no Moose::Util::TypeConstraints;
31 # register this as a metaclass alias ...
32 package # stop confusing PAUSE
33 Moose::Meta::Attribute::Custom::Trait::Getopt;
34 sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait' }
43 with 'MooseX::Getopt';
46 traits => [ 'Getopt' ],
49 default => 'file.dat',
51 # tells MooseX::Getopt to use --somedata as the
52 # command line flag instead of the normal
53 # autogenerated one (--data)
54 cmd_flag => 'somedata',
56 # tells MooseX::Getopt to also allow --moosedata,
57 # -m, and -d as aliases for this same option on
59 cmd_aliases => [qw/ moosedata m d /],
61 # Or, you can use a plain scalar for a single alias:
67 This is a custom attribute metaclass trait which can be used to
68 specify a the specific command line flag to use instead of the
69 default one which L<MooseX::Getopt> will create for you.
73 Changes the commandline flag to be this value, instead of the default,
74 which is the same as the attribute name.
76 =method B<cmd_aliases>
78 Adds more aliases for this commandline flag, useful for short options
81 =method B<has_cmd_flag>
83 =method B<has_cmd_aliases>