| 1 | # ABSTRACT: get document details | ||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Smartcat::App::Command::document; | ||||||||||
| 6 | 2 | ▶ | use Smartcat::App -command; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 0 | ▶ | sub opt_spec { | ||||||||
|
Subroutine
opt_spec: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 9 | 0 | my ($self) = @_; | |||||||||
| 10 | |||||||||||
| 11 | 0 | my @opts = $self->SUPER::opt_spec(); | |||||||||
| 12 | |||||||||||
| 13 | 0 | push @opts, | |||||||||
| 14 | [ 'document-ids|document-id:s@' => 'Document Ids' ], | ||||||||||
| 15 | [ 'delete' => 'Delete documents' ]; | ||||||||||
| 16 | |||||||||||
| 17 | 0 | return @opts; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | sub validate_args { | ||||||||
|
Subroutine
validate_args: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 21 | 0 | my ( $self, $opt, $args ) = @_; | |||||||||
| 22 | |||||||||||
| 23 | 0 | $self->SUPER::validate_args( $opt, $args ); | |||||||||
| 24 | $self->usage_error("'document_id' is required") | ||||||||||
| 25 | 0 | ▶ | unless defined $opt->{document_ids}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub get_and_print_document_details { | ||||||||
|
Subroutine
get_and_print_document_details: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 29 | 0 | my ( $self, $document_id ) = @_; | |||||||||
| 30 | 0 | my $document = $self->app->document_api->get_document($document_id); | |||||||||
| 31 | |||||||||||
| 32 | 0 | printf( | |||||||||
| 33 | "Document Details\n Name: '%s'\n Id: '%s'\n Status: '%s'\n DisassemblingStatus: '%s'\n", | ||||||||||
| 34 | $document->name, $document->id, $document->status, | ||||||||||
| 35 | $document->document_disassembling_status ); | ||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub execute { | ||||||||
|
Subroutine
execute: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 39 | 0 | my ( $self, $opt, $args ) = @_; | |||||||||
| 40 | 0 | ▶ | if ( defined $opt->{delete} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | $self->app->document_api->delete_documents( $opt->{document_ids} ); | |||||||||
| 42 | 0 | exit 0; | |||||||||
| 43 | } | ||||||||||
| 44 | 0 | $self->get_and_print_document_details($_) for @{ $opt->{document_ids} }; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 2 | 1; | |||||||||