| File: | blib/lib/Prophet/CLI/Command/Delete.pm |
| Coverage: | 84.6% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package Prophet::CLI::Command::Delete; | ||||||
| 2 | 5 5 5 | 54 27 125 | use Any::Moose; | ||||
| 3 | extends 'Prophet::CLI::Command'; | ||||||
| 4 | with 'Prophet::CLI::RecordCommand'; | ||||||
| 5 | |||||||
| 6 | sub usage_msg { | ||||||
| 7 | 4 | 0 | 25 | my $self = shift; | |||
| 8 | 4 | 30 | my ($cmd, $type_and_subcmd) = $self->get_cmd_and_subcmd_names; | ||||
| 9 | |||||||
| 10 | 4 | 11 | return <<"END_USAGE"; | ||||
| 11 | usage: ${cmd}${type_and_subcmd} <id> | ||||||
| 12 | END_USAGE | ||||||
| 13 | } | ||||||
| 14 | |||||||
| 15 | sub run { | ||||||
| 16 | 11 | 0 | 39 | my $self = shift; | |||
| 17 | |||||||
| 18 | 11 | 55 | $self->print_usage if $self->has_arg('h'); | ||||
| 19 | |||||||
| 20 | 7 | 217 | $self->require_uuid; | ||||
| 21 | 7 | 83 | my $record = $self->_load_record; | ||||
| 22 | |||||||
| 23 | 7 | 77 | if ( $record->delete ) { | ||||
| 24 | 7 | 185 | print $record->type . " " . $record->uuid . " deleted.\n"; | ||||
| 25 | } else { | ||||||
| 26 | 0 | print $record->type . " " . $record->uuid . "could not be deleted.\n"; | |||||
| 27 | } | ||||||
| 28 | |||||||
| 29 | } | ||||||
| 30 | |||||||
| 31 | __PACKAGE__->meta->make_immutable; | ||||||
| 32 | 5 5 5 | 83 20 39 | no Any::Moose; | ||||
| 33 | |||||||
| 34 | 1; | ||||||
| 35 | |||||||