| 1 | package App::SD::CLI::Command::Ticket::Comment::Create; | ||
| 2 | use Any::Moose; | ||
| 3 | |||
| 4 | extends 'Prophet::CLI::Command::Create'; | ||
| 5 | with 'App::SD::CLI::Model::TicketComment'; | ||
| 6 | with 'App::SD::CLI::Command'; | ||
| 7 | |||
| 8 | sub ARG_TRANSLATIONS { shift->SUPER::ARG_TRANSLATIONS(), f => 'file', m => 'content' }; | ||
| 9 | |||
| 10 | sub usage_msg { | ||
| 11 | my $self = shift; | ||
| 12 | my ($cmd, $type_and_subcmd) = $self->get_cmd_and_subcmd_names; | ||
| 13 | |||
| 14 | return <<"END_USAGE"; | ||
| 15 | usage: ${cmd}${type_and_subcmd} <ticket-id> [--edit] | ||
| 16 | ${cmd}${type_and_subcmd} <ticket-id> -- content="message here" | ||
| 17 | END_USAGE | ||
| 18 | } | ||
| 19 | |||
| 20 | # override args to feed in that ticket's uuid as an argument to the comment | ||
| 21 | sub run { | ||
| 22 | my $self = shift; | ||
| 23 | |||
| 24 | $self->print_usage if $self->has_arg('h'); | ||
| 25 | |||
| 26 | $self->require_uuid; | ||
| 27 | |||
| 28 | my $content = $self->get_content(type => 'comment', default_edit => 1); | ||
| 29 | |||
| 30 | die "Aborted.\n" | ||
| 31 | if length($content) == 0; | ||
| 32 | |||
| 33 | $self->set_prop(ticket => $self->uuid); | ||
| 34 | $self->set_prop(content => $content); | ||
| 35 | $self->SUPER::run(@_); | ||
| 36 | } | ||
| 37 | |||
| 38 | __PACKAGE__->meta->make_immutable; | ||
| 39 | no Any::Moose; | ||
| 40 | |||
| 41 | 1; | ||
| 42 |