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