App-SD
view release on metacpan or search on metacpan
lib/App/SD/CLI/Command/Ticket/Show.pm view on Meta::CPAN
package App::SD::CLI::Command::Ticket::Show;
use Any::Moose;
extends 'Prophet::CLI::Command::Show';
with 'App::SD::CLI::Command';
with 'App::SD::CLI::Model::Ticket';
sub ARG_TRANSLATIONS {
shift->SUPER::ARG_TRANSLATIONS(),
a => 'all-props',
s => 'skip-history',
h => 'with-history',
b => 'batch';
}
sub by_creation_date {
($a->can('created') ? $a->created : $a->prop('created') )
cmp
($b->can('created') ? $b->created : $b->prop('created') )
}
sub usage_msg {
my $self = shift;
my $cmd = shift || 'show';
my $script = $self->cli->get_script_name;
my $type = $self->type ? $self->type . q{ } : q{};
return <<"END_USAGE";
usage: ${script}${type}${cmd} <record-id> [options]
Options are:
-a|--all-props Show props even if they aren't common
-s|--skip-history Don't show ticket history
-h|--with-history Show ticket history even if disabled in config
-b|--batch
END_USAGE
}
override run => sub {
my $self = shift;
$self->print_usage if $self->has_arg('h');
$self->require_uuid;
my $record = $self->_load_record;
# prophet uses --verbose to decide whether to show all declared props
# or not (rather than just the ones returned by props_to_show),
# but --all-props is more consistent with sd's behaviour in update/create
if ( $self->has_arg('all-props') ) {
$self->set_arg( 'verbose' => 1 );
}
print "\n= METADATA\n\n";
super();
my @history = sort by_creation_date ( @{ $record->comments }, $record->changesets );
my @attachments = sort by_creation_date @{ $record->attachments };
if (@attachments) {
print "\n= ATTACHMENTS\n\n";
$self->show_attachment($_) for @attachments;
}
# allow user to not display history by specifying the --skip-history
# arg or setting ticket.no-implicit-history-display config item to a
# true value (can be overridden with --with-history)
if (!$self->has_arg('skip-history')
&& ( !$self->app_handle->config->get(
key => 'ticket.no-implicit-history-display',
( run in 1.249 second using v1.01-cache-2.11-cpan-5b529ec07f3 )