FIX: check listing parameter
This commit is contained in:
parent
51c07253f5
commit
9774167d16
@ -7,55 +7,86 @@ extends qw(App::Git::IssueManager);
|
|||||||
use Git::LowLevel;
|
use Git::LowLevel;
|
||||||
use Git::IssueManager;
|
use Git::IssueManager;
|
||||||
use Git::IssueManager::Issue;
|
use Git::IssueManager::Issue;
|
||||||
|
use Text::ANSITable;
|
||||||
use Term::ANSIColor;
|
use Term::ANSIColor;
|
||||||
use Try::Tiny;
|
use Try::Tiny;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
command_short_description 'list issues of a repository';
|
command_short_description 'list issues of a repository';
|
||||||
command_usage 'git issue list';
|
command_usage 'git issue list';
|
||||||
|
|
||||||
|
option 'show_status' => (
|
||||||
option 'use_color' => (
|
is => 'rw',
|
||||||
is => 'ro',
|
isa => 'ArrayRef[Str]',
|
||||||
isa => 'Bool',
|
|
||||||
required => 0,
|
required => 0,
|
||||||
documentation => q[use anso color to highlight critical issues],
|
documentation => q[select which issues with which stati should be displayd (open, assigned, inprogress, closed, all)],
|
||||||
cmd_aliases => [qw(color)],
|
cmd_aliases => [qw(s)],
|
||||||
default => 1
|
default => sub {return ["open"];}
|
||||||
);
|
);
|
||||||
|
|
||||||
sub run
|
sub run
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
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);
|
||||||
|
|
||||||
|
my @all_stati=("open","closed","assigned","inprogress");
|
||||||
|
|
||||||
|
# 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']);
|
||||||
|
}
|
||||||
|
|
||||||
my $manager = Git::IssueManager->new(repository=>Git::LowLevel->new(git_dir=> "."));
|
my $manager = Git::IssueManager->new(repository=>Git::LowLevel->new(git_dir=> "."));
|
||||||
if (!$manager->ready)
|
if (!$manager->ready)
|
||||||
{
|
{
|
||||||
print("IssueManager not initialized yet. Please call \"init\" command to do so.");
|
print("IssueManager not initialized yet. Please call \"init\" command to do so.");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
binmode(STDOUT, ":utf8");
|
||||||
my @issues=$manager->list();
|
my @issues=$manager->list();
|
||||||
print color('reset');
|
|
||||||
|
|
||||||
|
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};
|
||||||
for my $i (@issues)
|
for my $i (@issues)
|
||||||
{
|
{
|
||||||
if ($self->use_color && ($i->priority eq "high" || $i->priority eq "urgent" || $i->severity eq "hight" || $i->severity eq "critical"))
|
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") )
|
||||||
{
|
{
|
||||||
print color('bold red');
|
$t->add_row([$i->id,$i->subject,$i->type, $i->priority,$i->severity,$i->status,$i->author,$i->worker],{bgcolor=>'c60505'});
|
||||||
}
|
|
||||||
elsif ($self->use_color && ($i->priority eq "medium" || $i->severity eq "medium"))
|
|
||||||
{
|
|
||||||
print color('bold yellow');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print color('reset');
|
$t->add_row([$i->id,$i->subject,$i->type, $i->priority,$i->severity,$i->status,$i->author,$i->worker]);
|
||||||
}
|
}
|
||||||
printf("%20s\t%15s\t%30s\t%10s\t%10s\t%20s\t%20s\n", $i->id, $i->type, $i->subject, $i->priority, $i->severity,
|
|
||||||
$i->author,$i->creation_date->ymd() . " " . $i->creation_date->hms());
|
|
||||||
}
|
}
|
||||||
print color('reset');
|
}
|
||||||
|
print $t->draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user