| 1 | package App::SD::CLI::Command::Ticket::Comments; | ||
| 2 | use Any::Moose; | ||
| 3 | |||
| 4 | extends 'Prophet::CLI::Command::Search'; | ||
| 5 | with 'Prophet::CLI::RecordCommand'; | ||
| 6 | with 'App::SD::CLI::Command'; | ||
| 7 | with 'App::SD::CLI::Model::Ticket'; | ||
| 8 | |||
| 9 | override usage_msg => sub { | ||
| 10 | my $self = shift; | ||
| 11 | my $cmd = $self->cli->get_script_name; | ||
| 12 | |||
| 13 | return <<"END_USAGE"; | ||
| 14 | usage: ${cmd}ticket comments <ticket-id> | ||
| 15 | |||
| 16 | END_USAGE | ||
| 17 | }; | ||
| 18 | |||
| 19 | sub run { | ||
| 20 | my $self = shift; | ||
| 21 | |||
| 22 | $self->print_usage if $self->has_arg('h'); | ||
| 23 | |||
| 24 | my $record = $self->_get_record_object; | ||
| 25 | |||
| 26 | $self->require_uuid; | ||
| 27 | $record->load( uuid => $self->uuid ); | ||
| 28 | |||
| 29 | if (@{$record->comments}) { | ||
| 30 | for my $entry ($self->sort_by_prop( 'created' => $record->comments)) { | ||
| 31 | print "id: ".$entry->luid." (".$entry->uuid.")\n"; | ||
| 32 | print "created: ".$entry->prop('created')."\n\n"; | ||
| 33 | print $entry->prop('content')."\n\n"; | ||
| 34 | } | ||
| 35 | } else { | ||
| 36 | print "No comments found\n"; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | __PACKAGE__->meta->make_immutable; | ||
| 41 | no Any::Moose; | ||
| 42 | |||
| 43 | 1; | ||
| 44 |