2018-07-04 10:45:42 +02:00
|
|
|
package App::Git::IssueManager::List;
|
|
|
|
#ABSTRACT: class implementing the add issue command of the GIT IssueManager
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use MooseX::App::Command;
|
|
|
|
extends qw(App::Git::IssueManager);
|
2018-09-10 22:43:42 +02:00
|
|
|
use Git::LowLevel;
|
2018-07-04 10:45:42 +02:00
|
|
|
use Git::IssueManager;
|
|
|
|
use Git::IssueManager::Issue;
|
2018-09-13 21:14:50 +02:00
|
|
|
use Text::ANSITable;
|
2018-07-04 10:45:42 +02:00
|
|
|
use Term::ANSIColor;
|
|
|
|
use Try::Tiny;
|
2018-09-13 21:14:50 +02:00
|
|
|
use Data::Dumper;
|
2018-07-04 10:45:42 +02:00
|
|
|
|
|
|
|
command_short_description 'list issues of a repository';
|
|
|
|
command_usage 'git issue list';
|
|
|
|
|
2018-09-13 21:14:50 +02:00
|
|
|
option 'show_status' => (
|
|
|
|
is => 'rw',
|
|
|
|
isa => 'ArrayRef[Str]',
|
|
|
|
required => 0,
|
|
|
|
documentation => q[select which issues with which stati should be displayd (open, assigned, inprogress, closed, all)],
|
|
|
|
cmd_aliases => [qw(s)],
|
|
|
|
default => sub {return ["open"];}
|
2018-07-04 10:45:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
sub run
|
|
|
|
{
|
|
|
|
my $self = shift;
|
2018-09-13 21:14:50 +02:00
|
|
|
my @stati=@{$self->show_status};
|
|
|
|
|
|
|
|
#remove all numbers from array
|
|
|
|
my @help;
|
|
|
|
for my $s (@stati)
|
|
|
|
{
|
|
|
|
push(@help,$s) unless $s =~/^\d+$/;
|
|
|
|
}
|
|
|
|
@stati=@help;
|
|
|
|
$self->show_status(\@help);
|
|
|
|
|
2018-09-13 21:24:15 +02:00
|
|
|
my @all_stati=("open","closed","assigned","inprogress","all");
|
2018-09-13 21:14:50 +02:00
|
|
|
|
|
|
|
# check if a wrong status is requested
|
|
|
|
for my $s (@{$self->show_status})
|
|
|
|
{
|
|
|
|
if(!grep( /^$s$/, @all_stati ))
|
|
|
|
{
|
|
|
|
die("ERROR: unkown status \"" . $s . "\"\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# check if all issues are requested
|
|
|
|
|
|
|
|
if (grep( /^all$/, @stati ) )
|
|
|
|
{
|
|
|
|
$self->show_status(['open','closed','inprogress','assigned']);
|
|
|
|
}
|
|
|
|
|
2018-09-10 22:43:42 +02:00
|
|
|
my $manager = Git::IssueManager->new(repository=>Git::LowLevel->new(git_dir=> "."));
|
2018-07-04 10:45:42 +02:00
|
|
|
if (!$manager->ready)
|
|
|
|
{
|
|
|
|
print("IssueManager not initialized yet. Please call \"init\" command to do so.");
|
|
|
|
exit(-1);
|
|
|
|
}
|
2018-09-13 21:14:50 +02:00
|
|
|
binmode(STDOUT, ":utf8");
|
2018-07-04 10:45:42 +02:00
|
|
|
my @issues=$manager->list();
|
|
|
|
|
2018-09-13 21:14:50 +02:00
|
|
|
my $t = Text::ANSITable->new;
|
|
|
|
$t->use_utf8(1);
|
|
|
|
$t->use_color(1);
|
|
|
|
$t->use_box_chars(1);
|
|
|
|
$t->border_style('Default::single_boxchar');
|
|
|
|
$t->columns(["ID", "Subject", "Type", "Priority", "Severity", "Status", "Author", "Worker"]);
|
|
|
|
@stati=@{$self->show_status};
|
2018-07-04 10:45:42 +02:00
|
|
|
for my $i (@issues)
|
|
|
|
{
|
2018-09-13 21:14:50 +02:00
|
|
|
my $status=$i->status;
|
|
|
|
if ( grep( /^$status$/, @stati ) ) {
|
|
|
|
if ( $i->priority eq "high" || $i->priority eq "urgent" || ($i->severity eq "high") || ($i->severity eq "critical") )
|
|
|
|
{
|
|
|
|
$t->add_row([$i->id,$i->subject,$i->type, $i->priority,$i->severity,$i->status,$i->author,$i->worker],{bgcolor=>'c60505'});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->add_row([$i->id,$i->subject,$i->type, $i->priority,$i->severity,$i->status,$i->author,$i->worker]);
|
|
|
|
}
|
2018-07-04 10:45:42 +02:00
|
|
|
}
|
|
|
|
}
|
2018-09-13 21:14:50 +02:00
|
|
|
print $t->draw;
|
2018-07-04 10:45:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|