| 1 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package Smartcat::App::Command; | ||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use App::Cmd::Setup -command; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Cwd qw(abs_path); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | sub opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 11 | return ( | ||||||||||||||||||||||||||||
| 12 | #[ 'config:s' => 'Config file path' ], | ||||||||||||||||||||||||||||
| 13 | 2 | [ 'token-id:s' => 'Smartcat account id' ], | |||||||||||||||||||||||||||
| 14 | [ 'token:s' => 'API token' ], | ||||||||||||||||||||||||||||
| 15 | [ 'log:s' => 'Log file path' ], | ||||||||||||||||||||||||||||
| 16 | [ 'base-url:s' => 'Base Smartcat URL' ], | ||||||||||||||||||||||||||||
| 17 | [ 'debug' => 'Debug mode' ] | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | sub project_id_opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
project_id_opt_spec: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 2 | return ( [ 'project-id:s' => 'Project Id' ], ); | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub project_workdir_opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
project_workdir_opt_spec: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 0 | return ( [ 'project-workdir:s' => 'Project translation files path' ], ); | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub file_params_opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
file_params_opt_spec: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | return ( | ||||||||||||||||||||||||||||
| 31 | 0 | [ 'filetype:s' => 'Type of translation files' ], | |||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub extract_id_from_name_opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
extract_id_from_name_opt_spec: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | return ( | ||||||||||||||||||||||||||||
| 37 | 0 | [ 'extract-id-from-name' => 'Extract stable external document identifiers from filenames in "name---id.ext" format for comparison and automatic renaming' ], | |||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub external_tag_opt_spec { | ||||||||||||||||||||||||||
|
Subroutine
external_tag_opt_spec: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | return ( | ||||||||||||||||||||||||||||
| 43 | 0 | ['external-tag:s' => 'Set custom external tag for project. Default value: "source:Serge"'] | |||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub validate_file_params { | ||||||||||||||||||||||||||
|
Subroutine
validate_file_params: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 0 | my ( $self, $opt, $args ) = @_; | |||||||||||||||||||||||||||
| 49 | 0 | my $rundata = $self->app->{rundata}; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | $rundata->{filetype} = defined $opt->{filetype} ? $opt->{filetype} : '.po'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 2 | ▶ | sub validate_project_id { | ||||||||||||||||||||||||||
|
Subroutine
validate_project_id: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 2 | my ( $self, $opt, $args ) = @_; | |||||||||||||||||||||||||||
| 55 | 2 | my $rundata = $self->app->{rundata}; | |||||||||||||||||||||||||||
| 56 | $self->usage_error("'project_id' is required") | ||||||||||||||||||||||||||||
| 57 | 2 | ▶ | unless defined $opt->{project_id}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 2 | $rundata->{project_id} = $opt->{project_id}; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub validate_project_workdir { | ||||||||||||||||||||||||||
|
Subroutine
validate_project_workdir: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 0 | my ( $self, $opt, $args ) = @_; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | my $rundata = $self->app->{rundata}; | |||||||||||||||||||||||||||
| 65 | $self->app->usage_error( | ||||||||||||||||||||||||||||
| 66 | "'project_workdir', which is set to '$opt->{project_workdir}', does not point to a valid directory" | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | ) unless -d $opt->{project_workdir}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | $rundata->{project_workdir} = abs_path( $opt->{project_workdir} ); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 2 | ▶ | sub validate_args { | ||||||||||||||||||||||||||
|
Subroutine
validate_args: called CC=10 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 2 | my ( $self, $opt, $args ) = @_; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 2 | my $app = $self->app; | |||||||||||||||||||||||||||
| 75 | 2 | my $rundata = $self->app->{rundata}; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 2 | ▶ | if ( defined $opt->{token_id} && defined $opt->{token} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $opt->{"token_id"} and defined $opt->{"token"}
MC/DC0%0/2
defined $opt->{"token_id"} and defined $opt->{"token"}
defined $opt->{"token_id"}
defined $opt->{"token"}
Truth table33%1/3
A and B
A= defined $opt->{"token_id"}B= defined $opt->{"token"}
| |||||||||||||||||||||||||||||
| 78 | 0 | $app->{config}->{username} = $opt->{token_id}; | |||||||||||||||||||||||||||
| 79 | 0 | $app->{config}->{password} = $opt->{token}; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 2 | ▶ | if ( defined $opt->{base_url} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | $app->{config}->{base_url} = $opt->{base_url}; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 2 | ▶ | if ( defined $opt->{log} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | $self->usage_error( | ||||||||||||||||||||||||||||
| 88 | "directory of 'log', which is set to '$opt->{log}', does not point to a valid directory" | ||||||||||||||||||||||||||||
| 89 | 1 | ▶ | ) unless -d dirname( $opt->{log} ) && -w _; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-d dirname($opt->{"log"}) and -w _
MC/DC0%0/2
-d dirname($opt->{"log"}) and -w _
-d dirname($opt->{"log"})
-w _
Truth table33%1/3
A and B
A= -d dirname($opt->{"log"})B= -w _
| |||||||||||||||||||||||||||||
| 90 | 1 | $app->{config}->{log} = $opt->{log}; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | $self->usage_error( | ||||||||||||||||||||||||||||
| 94 | "set auth params via 'config' command first or provide options '--token-id' and '--token'" | ||||||||||||||||||||||||||||
| 95 | ) | ||||||||||||||||||||||||||||
| 96 | unless ( defined $app->{config}->username | ||||||||||||||||||||||||||||
| 97 | 2 | ▶ | && defined $app->{config}->password ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $app->{"config"}->username and defined $app->{"config"}->password
MC/DC0%0/2
defined $app->{"config"}->username and defined $app->{"config"}->password
defined $app->{"config"}->username
defined $app->{"config"}->password
Truth table33%1/3
A and B
A= defined $app->{"config"}->usernameB= defined $app->{"config"}->password
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 2 | ▶ | $rundata->{debug} = 1 if defined $opt->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 2 | $app->init; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 2 | 1; | |||||||||||||||||||||||||||