| 1 | package App::JC::Client::addIssue; | ||
| 2 | #ABSTRACT: class implementing the add issue command of the jira client | ||
| 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 | |||
| 13 | command_short_description 'create an issue within a project'; | ||
| 14 | command_usage 'jc.pl add_issue <project> <type> <summary> <description>'; | ||
| 15 | |||
| 16 | |||
| 17 | option 'project' => ( | ||
| 18 | is => 'ro', | ||
| 19 | isa => 'Str', | ||
| 20 | required => 1, | ||
| 21 | documentation => q[The Project in which to create the issue], | ||
| 22 | cmd_aliases => [qw(p)], # Alternative option name | ||
| 23 | ); | ||
| 24 | |||
| 25 | option 'tasktype' => ( | ||
| 26 | is => 'ro', | ||
| 27 | isa => 'Str', | ||
| 28 | required => 0, | ||
| 29 | default => "Task", | ||
| 30 | documentation => q[what kind of issue to add], | ||
| 31 | cmd_aliases => [qw(t)], # Alternative option name | ||
| 32 | ); | ||
| 33 | |||
| 34 | |||
| 35 | option 'summary' => ( | ||
| 36 | is => 'ro', | ||
| 37 | isa => 'Str', | ||
| 38 | required => 1, | ||
| 39 | documentation => q[The summary of the issue], | ||
| 40 | cmd_aliases => [qw(s)], # Alternative option name | ||
| 41 | ); | ||
| 42 | |||
| 43 | option 'description' => ( | ||
| 44 | is => 'ro', | ||
| 45 | isa => 'Str', | ||
| 46 | required => 0, | ||
| 47 | default => "", | ||
| 48 | documentation => q[a description of the issue], | ||
| 49 | cmd_aliases => [qw(d)], # Alternative option name | ||
| 50 | ); | ||
| 51 | |||
| 52 | sub run | ||
| 53 | { | ||
| 54 | my $self = shift; | ||
| 55 | |||
| 56 | my $jira = JIRA::Client::Automated->new($self->url, $self->user, $self->pass); | ||
| 57 | my $issue = $jira->create_issue($self->project, $self->tasktype, $self->summary, $self->description); | ||
| 58 | |||
| 59 | if (!defined($issue)) | ||
| 60 | { | ||
| 61 | die("ERROR creating issue\n"); | ||
| 62 | } | ||
| 63 | |||
| 64 | } | ||
| 65 | |||
| 66 | 1; | ||
| 67 | |||
| 68 | __END__ |