File Coverage

blib/lib/Dist/Zilla/App/Command/issues.pm
Criterion Covered Total %
statement 23 24 95.8
branch 6 10 60.0
condition 2 6 33.3
subroutine 5 6 83.3
pod 3 3 100.0
total 39 49 79.5


line stmt bran cond sub pod time code
1 1     1   2259433 use strict;
  1         3  
  1         23  
2 1     1   5 use warnings;
  1         2  
  1         47  
3             package Dist::Zilla::App::Command::issues;
4             # ABSTRACT: Print the count of outstanding RT and github issues for your distribution
5             # vim: set ts=8 sts=4 sw=4 tw=115 et :
6              
7             our $VERSION = '0.009';
8              
9 1     1   5 use Dist::Zilla::App -command;
  1         1  
  1         8  
10              
11 0     0 1 0 sub abstract { "print your distribution's count of outstanding RT and github issues" }
12              
13             sub opt_spec
14             {
15 2     2 1 119402 [ 'all!' => 'check both RT and github, regardless of plugin configuration' ],
16             [ 'rt!' => 'get RT information', { default => 1 } ],
17             [ 'github!' => 'get github information', { default => 1 } ],
18             [ 'colour|color!' => 'Uses L<Term::ANSIColor> to colour-code the results according to severity', { default => 1 } ],
19             [ 'repo=s' => 'URL of the github repository' ],
20             }
21              
22             sub execute
23             {
24 2     2 1 2645 my ($self, $opt) = @_; # $arg
25              
26 2 50       11 $self->app->chrome->logger->mute unless $self->app->global_options->verbose;
27              
28             # parse dist.ini and load, instantiate all plugins
29 2         45649 my $zilla = $self->zilla;
30              
31 2         801793 my @plugins = grep { $_->isa('Dist::Zilla::Plugin::CheckIssues') } @{ $zilla->plugins };
  25         114  
  2         52  
32 2 50       42 if (not @plugins)
33             {
34 2         19 require Dist::Zilla::Plugin::CheckIssues;
35 2 50 33     20 push @plugins,
    50 33        
36             Dist::Zilla::Plugin::CheckIssues->new(
37             zilla => $zilla,
38             plugin_name => 'issues_command',
39             rt => ($opt->all || $opt->rt ? 1 : 0),
40             github => ($opt->all || $opt->github ? 1 : 0),
41             colour => $opt->colour,
42             );
43             }
44              
45 2 100       3956 $plugins[0]->repo_url($opt->repo) if $opt->repo;
46              
47 2         21 my @issues = $plugins[0]->get_issues;
48              
49 2         18 $self->app->chrome->logger->unmute;
50 2         113 $self->log($_) foreach @issues;
51             }
52              
53             1;
54              
55             __END__
56              
57             =pod
58              
59             =encoding UTF-8
60              
61             =head1 NAME
62              
63             Dist::Zilla::App::Command::issues - Print the count of outstanding RT and github issues for your distribution
64              
65             =head1 VERSION
66              
67             version 0.009
68              
69             =head1 SYNOPSIS
70              
71             $ dzil issues
72              
73             =head1 DESCRIPTION
74              
75             This is a command plugin for L<Dist::Zilla>. It provides the C<issues> command,
76             which acts as L<[CheckIssues|Dist::Zilla::Plugin::CheckIssues> would
77             during the build: prints the RT and/or github issue counts for your distribution.
78              
79             =head1 OPTIONS
80              
81             If you have C<[CheckIssues]> in your F<dist.ini>, its configuration is used
82             (with the exception of C<repo> which is always valid).
83             Otherwise, the command-line options come into play:
84              
85             =head2 --rt
86              
87             Checks your distribution's queue at L<https://rt.cpan.org/>. Defaults to true.
88             (You should leave this enabled even if you have your main issue list on github,
89             as sometimes tickets still end up on RT.)
90              
91             =head2 --github
92              
93             Checks the issue list on L<github|https://github.com> for your distribution; does
94             nothing if your distribution is not hosted on L<github|https://github.com>, as
95             listed in your distribution's metadata. Defaults to true.
96              
97             =head2 --all
98              
99             Same as --rt --github
100              
101             =head2 --colour or --color
102              
103             Uses L<Term::ANSIColor> to colour-code the results according to severity.
104             Defaults to true.
105              
106             =head2 --repo <string>
107              
108             The URL of the github repository. This is normally fetched from the
109             C<resources> field in metadata, but can be explicitly passed if your
110             distribution's plugins cannot yet determine the repository location (for
111             example you haven't configured the git remote spec).
112              
113             =head1 SEE ALSO
114              
115             =over 4
116              
117             =item *
118              
119             L<Dist::Zilla::Plugin::CheckIssues>
120              
121             =back
122              
123             =head1 SUPPORT
124              
125             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-CheckIssues>
126             (or L<bug-Dist-Zilla-Plugin-CheckIssues@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-CheckIssues@rt.cpan.org>).
127              
128             There is also a mailing list available for users of this distribution, at
129             L<http://dzil.org/#mailing-list>.
130              
131             There is also an irc channel available for users of this distribution, at
132             irc://irc.perl.org/#distzilla.
133              
134             I am also usually active on irc, as 'ether' at C<irc.perl.org>.
135              
136             =head1 AUTHOR
137              
138             Karen Etheridge <ether@cpan.org>
139              
140             =head1 COPYRIGHT AND LICENCE
141              
142             This software is copyright (c) 2014 by Karen Etheridge.
143              
144             This is free software; you can redistribute it and/or modify it under
145             the same terms as the Perl 5 programming language system itself.
146              
147             =cut