| 1 | package App::JC::Client::updateIssue; | ||
| 2 | #ABSTRACT: class implementing starting of an issue | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use MooseX::App::Command; | ||
| 6 | extends qw(App::JC::Client); | ||
| 7 | |||
| 8 | use Term::ANSIColor; | ||
| 9 | use Try::Tiny; | ||
| 10 | use JIRA::Client::Automated; | ||
| 11 | |||
| 12 | # the version of the module | ||
| 13 | our $VERSION = '0.001'; | ||
| 14 | |||
| 15 | command_short_description 'update an issue'; | ||
| 16 | command_usage 'jc.pl update -i <issuekey> <options>'; | ||
| 17 | |||
| 18 | |||
| 19 | option 'issuekey' => ( | ||
| 20 | is => 'ro', | ||
| 21 | isa => 'Str', | ||
| 22 | required => 1, | ||
| 23 | documentation => q[The key of the issue to update], | ||
| 24 | cmd_aliases => [qw(i)], # Alternative option name | ||
| 25 | ); | ||
| 26 | |||
| 27 | option 'estimatedTime' => ( | ||
| 28 | is => 'ro', | ||
| 29 | isa => 'Str', | ||
| 30 | required => 0, | ||
| 31 | documentation => q[The estimatedTime of finish for the Issue (10m, 2d, 1w, ...)], | ||
| 32 | cmd_aliases => [qw(e)], # Alternative option name | ||
| 33 | ); | ||
| 34 | |||
| 35 | |||
| 36 | sub run | ||
| 37 | { | ||
| 38 | my $self = shift; | ||
| 39 | |||
| 40 | my $jira = JIRA::Client::Automated->new($self->url, $self->user, $self->pass); | ||
| 41 | |||
| 42 | my $issue = $jira->get_issue($self->issuekey); | ||
| 43 | if (!defined($issue)) | ||
| 44 | { | ||
| 45 | die("ERROR: issue does not exist\n"); | ||
| 46 | } | ||
| 47 | |||
| 48 | my $update; | ||
| 49 | |||
| 50 | if ($self->estimatedTime=~/\S+/) | ||
| 51 | { | ||
| 52 | $update->{timetracking}->{originalEstimate}=$self->estimatedTime; | ||
| 53 | } | ||
| 54 | |||
| 55 | $issue=$jira->update_issue($self->issuekey, $update); | ||
| 56 | |||
| 57 | } | ||
| 58 | |||
| 59 | 1; | ||
| 60 | |||
| 61 | __END__ |