File Coverage

blib/lib/App/Midgen/Role/Options.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package App::Midgen::Role::Options;
2              
3 2     2   17357 use Types::Standard qw( Bool Int );
  2         111561  
  2         23  
4 2     2   1559 use Moo::Role;
  2         4  
  2         18  
5              
6             # Load time and dependencies negate execution time
7             # use namespace::clean -except => 'meta';
8              
9             our $VERSION = '0.33_05';
10             $VERSION = eval $VERSION; ## no critic
11              
12 2     2   832 use Carp;
  2         3  
  2         712  
13              
14             #######
15             # cmd line options
16             #######
17              
18             has 'core' => (
19             is => 'ro',
20             isa => Bool,
21             default => sub {0},
22             required => 1,
23             );
24              
25             has 'debug' => (
26             is => 'ro',
27             isa => Bool,
28             default => sub {0},
29             required => 1,
30             );
31              
32             has 'dual_life' => (
33             is => 'ro',
34             isa => Bool,
35             default => sub {0},
36             required => 1,
37             );
38              
39             has 'experimental' => (
40             is => 'ro',
41             isa => Bool,
42             default => sub {0},
43             required => 1,
44             );
45              
46             has 'format' => (
47             is => 'ro',
48             isa => sub {
49             my $format = {
50             dsl => 1,
51             mi => 1,
52             mb => 1,
53             eumm => 1,
54             dist => 1,
55             cpanfile => 1,
56             metajson => 1,
57             infile => 1
58             };
59             croak 'not a supported output format' unless defined $format->{ $_[0] };
60             return;
61             },
62             default => 'dsl',
63             required => 1,
64             );
65              
66             has 'quiet' => (
67             is => 'ro',
68             isa => Bool,
69             default => sub {0},
70             required => 1,
71             );
72              
73             has 'verbose' => (
74             is => 'ro',
75             isa => Int,
76             default => sub {1},
77             required => 1,
78             );
79              
80             has 'zero' => (
81             is => 'ro',
82             isa => Bool,
83             default => sub {0},
84             required => 1,
85             );
86              
87             around [qw( debug verbose )] => sub {
88             my $orig = shift;
89             my $self = shift;
90             my $content = $self->$orig(@_);
91              
92             if ( ( $self->quiet == 1 && $self->experimental == 1 )
93             || ( $self->format eq 'infile' ) )
94             {
95             return 0;
96             } else {
97             return $content;
98             }
99             };
100              
101              
102 2     2   11 no Moo::Role;
  2         4  
  2         10  
103              
104             1;
105              
106             __END__
107              
108             =pod
109              
110             =encoding UTF-8
111              
112             =head1 NAME
113              
114             App::Midgen::Role::Options - Package Options used by L<App::Midgen>
115              
116             =head1 VERSION
117              
118             version: 0.33_05
119              
120             =head1 METHODS
121              
122             none as such, but we do have
123              
124             =head2 OPTIONS
125              
126             =over 4
127              
128             =item * core
129              
130             =item * debug
131              
132             =item * dual_life
133              
134             =item * experimental
135              
136             =item * format
137              
138             =item * quiet
139              
140             =item * verbose
141              
142             0 -> off
143             1 -> default # -v
144             2 -> show files # -vv
145              
146             =item * zero
147              
148             =back
149              
150             for more info see L<midgen>
151              
152             =head1 SEE ALSO
153              
154             L<App::Midgen>,
155              
156             =head1 AUTHOR
157              
158             See L<App::Midgen>
159              
160             =head2 CONTRIBUTORS
161              
162             See L<App::Midgen>
163              
164             =head1 COPYRIGHT
165              
166             See L<App::Midgen>
167              
168             =head1 LICENSE
169              
170             This library is free software; you can redistribute it and/or modify
171             it under the same terms as Perl itself.
172              
173             =cut