| 1 | # ABSTRACT: get project 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::project; | ||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Smartcat::App -command; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | sub opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 9 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | my @opts = $self->SUPER::opt_spec; | |||||||||||||||||||||||||||
| 12 | 2 | push @opts, $self->project_id_opt_spec, [ 'list' => 'Get all projects' ]; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | return @opts; | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | sub validate_args { | ||||||||||||||||||||||||||
|
Subroutine
validate_args: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 2 | my ( $self, $opt, $args ) = @_; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | $self->SUPER::validate_args( $opt, $args ); | |||||||||||||||||||||||||||
| 21 | $self->usage_error( | ||||||||||||||||||||||||||||
| 22 | "'--list' option cannot be used together with '--project-id'") | ||||||||||||||||||||||||||||
| 23 | 2 | ▶ | if ( defined $opt->{list} && defined $opt->{project_id} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $opt->{"list"} and defined $opt->{"project_id"}
MC/DC0%0/2
defined $opt->{"list"} and defined $opt->{"project_id"}
defined $opt->{"list"}
defined $opt->{"project_id"}
Truth table33%1/3
A and B
A= defined $opt->{"list"}B= defined $opt->{"project_id"}
| |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | $self->validate_project_id( $opt, $args ) unless defined $opt->{list}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 2 | ▶ | sub print_project_details { | ||||||||||||||||||||||||||
|
Subroutine
print_project_details: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 2 | my ( $self, $project ) = @_; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | print "Project:\n\t" . $project->name . "\n"; | |||||||||||||||||||||||||||
| 31 | 2 | print "Id:\n\t" . $project->id . "\n"; | |||||||||||||||||||||||||||
| 32 | 2 | print "Documents:\n"; | |||||||||||||||||||||||||||
| 33 | print "\t" | ||||||||||||||||||||||||||||
| 34 | . $_->name | ||||||||||||||||||||||||||||
| 35 | . "\n\t\tid: $_->{id}\n\t\tstatus: " | ||||||||||||||||||||||||||||
| 36 | . $_->status | ||||||||||||||||||||||||||||
| 37 | . "\n\t\tlanguage: " | ||||||||||||||||||||||||||||
| 38 | . $_->target_language . "\n" | ||||||||||||||||||||||||||||
| 39 | 2 | for @{ $project->documents }; | |||||||||||||||||||||||||||
| 40 | 2 | print "Target languages:\n"; | |||||||||||||||||||||||||||
| 41 | 2 | print "\t" . join( ' ', @{ $project->target_languages } ) . "\n"; | |||||||||||||||||||||||||||
| 42 | 2 | print "Status:\n\t" . $project->status . "\n"; | |||||||||||||||||||||||||||
| 43 | 2 | print "-" x 80; | |||||||||||||||||||||||||||
| 44 | 2 | print "\n"; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub print_project { | ||||||||||||||||||||||||||
|
Subroutine
print_project: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 0 | my ( $self, $project ) = @_; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | print "Project:\n\t" . $project->name . "\n"; | |||||||||||||||||||||||||||
| 51 | 0 | print "Id:\n\t" . $project->id . "\n"; | |||||||||||||||||||||||||||
| 52 | 0 | print "Number of documents:\n"; | |||||||||||||||||||||||||||
| 53 | 0 | print "\t" . @{ $project->documents } . "\n"; | |||||||||||||||||||||||||||
| 54 | 0 | print "Target languages:\n"; | |||||||||||||||||||||||||||
| 55 | 0 | print "\t" . join( ' ', @{ $project->target_languages } ) . "\n"; | |||||||||||||||||||||||||||
| 56 | 0 | print "Status:\n\t" . $project->status . "\n"; | |||||||||||||||||||||||||||
| 57 | 0 | print "-" x 80; | |||||||||||||||||||||||||||
| 58 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 2 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=3 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | 2 | my ( $self, $opt, $args ) = @_; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 2 | my $api = $self->app->project_api; | |||||||||||||||||||||||||||
| 65 | 2 | ▶ | if ( defined $opt->{list} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | my $projects = $api->get_all_projects; | |||||||||||||||||||||||||||
| 67 | 0 | print "Total number of projects:\n\t" . @$projects . "\n"; | |||||||||||||||||||||||||||
| 68 | 0 | print "-" x 80; | |||||||||||||||||||||||||||
| 69 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 70 | 0 | $self->print_project($_) for @$projects; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | else { | ||||||||||||||||||||||||||||
| 73 | 2 | $self->print_project_details( $api->get_project ); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 2 | 1; | |||||||||||||||||||||||||||