File Coverage

blib/lib/MooseX/Getopt/Explicit.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             ## no critic (RequireUseStrict)
2             package MooseX::Getopt::Explicit;
3             {
4             $MooseX::Getopt::Explicit::VERSION = '0.02';
5             }
6              
7             ## use critic (RequireUseStrict)
8 2     2   4506 use Moose::Role;
  2         8794  
  2         16  
9              
10             with 'MooseX::Getopt';
11              
12             around _compute_getopt_attrs => sub {
13             my ( $orig, $self, @args ) = @_;
14              
15             my @attrs = $self->$orig(@args);
16              
17             return grep {
18             $_->does('MooseX::Getopt::Meta::Attribute::Trait')
19             } @attrs;
20             };
21              
22             1;
23              
24              
25              
26             =pod
27              
28             =head1 NAME
29              
30             MooseX::Getopt::Explicit - MooseX::Getopt, but without implicit option generation
31              
32             =head1 VERSION
33              
34             version 0.02
35              
36             =head1 SYNOPSIS
37              
38             use Moose;
39             with 'MooseX::Getopt::Explicit';
40              
41             has foo => (
42             is => 'rw',
43             ); # Does *not* cause a Getopt option to be generated!
44              
45             has bar => (
46             is => 'ro'
47             isa => 'Str',
48             traits => ['Getopt'],
49             ); # *Does* cause a Getopt option to be generated!
50              
51             =head1 DESCRIPTION
52              
53             B<NOTE> I didn't know about L<MooseX::Getopt::Strict> when I wrote this; use
54             that instead!
55              
56             L<MooseX::Getopt> is nice, but I don't care for how it creates a command
57             line option for every attribute in my classes unless explicitly overridden.
58             So this role does the opposite: it requires C<traits =E<gt> ['Getopt']> in
59             order for a command line option to be generated.
60              
61             =head1 SEE ALSO
62              
63             L<MooseX::Getopt>
64              
65             =head1 AUTHOR
66              
67             Rob Hoelz <rob@hoelz.ro>
68              
69             =head1 COPYRIGHT AND LICENSE
70              
71             This software is copyright (c) 2012 by Rob Hoelz.
72              
73             This is free software; you can redistribute it and/or modify it under
74             the same terms as the Perl 5 programming language system itself.
75              
76             =head1 BUGS
77              
78             Please report any bugs or feature requests on the bugtracker website
79             https://github.com/hoelzro/moosex-getopt-explicit/issues
80              
81             When submitting a bug or request, please include a test-file or a
82             patch to an existing test-file that illustrates the bug or desired
83             feature.
84              
85             =cut
86              
87              
88             __END__
89              
90             # ABSTRACT: MooseX::Getopt, but without implicit option generation
91