App-Git-IssueManager/lib/App/Git/IssueManager/List.pm

62 lines
1.6 KiB
Perl
Raw Normal View History

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);
use Git::RepositoryHL;
use Git::IssueManager;
use Git::IssueManager::Issue;
use Term::ANSIColor;
use Try::Tiny;
command_short_description 'list issues of a repository';
command_usage 'git issue list';
option 'use_color' => (
is => 'ro',
isa => 'Bool',
required => 0,
documentation => q[use anso color to highlight critical issues],
cmd_aliases => [qw(color)],
default => 1
);
sub run
{
my $self = shift;
my $manager = Git::IssueManager->new(repository=>Git::RepositoryHL->new(git_dir=> "."));
if (!$manager->ready)
{
print("IssueManager not initialized yet. Please call \"init\" command to do so.");
exit(-1);
}
my @issues=$manager->list();
print color('reset');
for my $i (@issues)
{
if ($self->use_color && ($i->priority eq "high" || $i->priority eq "urgent" || $i->severity eq "hight" || $i->severity eq "critical"))
{
print color('bold red');
}
elsif ($self->use_color && ($i->priority eq "medium" || $i->severity eq "medium"))
{
print color('bold yellow');
}
else
{
print color('reset');
}
printf("%20s\t%15s\t%50s\t%10s\t%10s\t%20s\n", $i->id, $i->type, $i->subject, $i->priority, $i->severity,
$i->creation_date->ymd() . " " . $i->creation_date->hms());
}
print color('reset');
}
1;