File Coverage

blib/lib/Dist/Zilla/App/Command/issues.pm
Criterion Covered Total %
statement 24 25 96.0
branch 6 10 60.0
condition 2 6 33.3
subroutine 6 7 85.7
pod 3 3 100.0
total 41 51 80.3


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