| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooseX::Getopt::Meta::Attribute::Trait; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Optional meta attribute trait for custom option names |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.75'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
27
|
|
|
27
|
|
18437
|
use Moose::Role; |
|
|
27
|
|
|
|
|
208
|
|
|
|
27
|
|
|
|
|
221
|
|
|
7
|
27
|
|
|
27
|
|
142550
|
use Moose::Util::TypeConstraints qw(subtype coerce from via as); |
|
|
27
|
|
|
|
|
67
|
|
|
|
27
|
|
|
|
|
289
|
|
|
8
|
27
|
|
|
27
|
|
24211
|
use namespace::autoclean; |
|
|
27
|
|
|
|
|
75
|
|
|
|
27
|
|
|
|
|
211
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'cmd_flag' => ( |
|
11
|
|
|
|
|
|
|
is => 'rw', |
|
12
|
|
|
|
|
|
|
isa => 'Str', |
|
13
|
|
|
|
|
|
|
predicate => 'has_cmd_flag', |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# This subtype is to support scalar -> arrayref coercion |
|
17
|
|
|
|
|
|
|
# without polluting the built-in types |
|
18
|
|
|
|
|
|
|
my $cmd_aliases = subtype as 'ArrayRef'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
coerce $cmd_aliases |
|
21
|
|
|
|
|
|
|
=> from 'Str' |
|
22
|
|
|
|
|
|
|
=> via { [$_] }; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'cmd_aliases' => ( |
|
25
|
|
|
|
|
|
|
is => 'rw', |
|
26
|
|
|
|
|
|
|
isa => $cmd_aliases, |
|
27
|
|
|
|
|
|
|
predicate => 'has_cmd_aliases', |
|
28
|
|
|
|
|
|
|
coerce => 1, |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# register this as a metaclass alias ... |
|
32
|
|
|
|
|
|
|
package # stop confusing PAUSE |
|
33
|
|
|
|
|
|
|
Moose::Meta::Attribute::Custom::Trait::Getopt; |
|
34
|
25
|
|
|
25
|
|
35187
|
sub register_implementation { 'MooseX::Getopt::Meta::Attribute::Trait' } |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=pod |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=encoding UTF-8 |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
MooseX::Getopt::Meta::Attribute::Trait - Optional meta attribute trait for custom option names |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 VERSION |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
version 0.75 |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
package App; |
|
55
|
|
|
|
|
|
|
use Moose; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
with 'MooseX::Getopt'; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has 'data' => ( |
|
60
|
|
|
|
|
|
|
traits => [ 'Getopt' ], |
|
61
|
|
|
|
|
|
|
is => 'ro', |
|
62
|
|
|
|
|
|
|
isa => 'Str', |
|
63
|
|
|
|
|
|
|
default => 'file.dat', |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# tells MooseX::Getopt to use --somedata as the |
|
66
|
|
|
|
|
|
|
# command line flag instead of the normal |
|
67
|
|
|
|
|
|
|
# autogenerated one (--data) |
|
68
|
|
|
|
|
|
|
cmd_flag => 'somedata', |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# tells MooseX::Getopt to also allow --moosedata, |
|
71
|
|
|
|
|
|
|
# -m, and -d as aliases for this same option on |
|
72
|
|
|
|
|
|
|
# the commandline. |
|
73
|
|
|
|
|
|
|
cmd_aliases => [qw/ moosedata m d /], |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Or, you can use a plain scalar for a single alias: |
|
76
|
|
|
|
|
|
|
cmd_aliases => 'm', |
|
77
|
|
|
|
|
|
|
); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This is a custom attribute metaclass trait which can be used to |
|
82
|
|
|
|
|
|
|
specify a the specific command line flag to use instead of the |
|
83
|
|
|
|
|
|
|
default one which L<MooseX::Getopt> will create for you. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 METHODS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 B<cmd_flag> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Changes the command-line flag to be this value, instead of the default, |
|
90
|
|
|
|
|
|
|
which is the same as the attribute name. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 B<cmd_aliases> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Adds more aliases for this command-line flag, useful for short options |
|
95
|
|
|
|
|
|
|
and such. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 B<has_cmd_flag> |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 B<has_cmd_aliases> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SUPPORT |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Getopt> |
|
104
|
|
|
|
|
|
|
(or L<bug-MooseX-Getopt@rt.cpan.org|mailto:bug-MooseX-Getopt@rt.cpan.org>). |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
|
107
|
|
|
|
|
|
|
L<http://lists.perl.org/list/moose.html>. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
|
110
|
|
|
|
|
|
|
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Stevan Little <stevan@iinteractive.com> |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This software is copyright (c) 2007 by Infinity Interactive, Inc. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
121
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |