| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
2640
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
55
|
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
76
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Smartcat::App::Command; |
|
5
|
2
|
|
|
2
|
|
8
|
use App::Cmd::Setup -command; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1734
|
use Cwd qw(abs_path); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
134
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use File::Basename; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
1177
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub opt_spec { |
|
11
|
|
|
|
|
|
|
return ( |
|
12
|
|
|
|
|
|
|
#[ 'config:s' => 'Config file path' ], |
|
13
|
2
|
|
|
2
|
1
|
17
|
[ '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
|
|
|
|
|
|
|
sub project_id_opt_spec { |
|
22
|
2
|
|
|
2
|
0
|
9
|
return ( [ 'project-id:s' => 'Project Id' ], ); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub project_workdir_opt_spec { |
|
26
|
0
|
|
|
0
|
0
|
0
|
return ( [ 'project-workdir:s' => 'Project translation files path' ], ); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub file_params_opt_spec { |
|
30
|
|
|
|
|
|
|
return ( |
|
31
|
0
|
|
|
0
|
0
|
0
|
[ 'filetype:s' => 'Type of translation files' ], |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub extract_id_from_name_opt_spec { |
|
36
|
|
|
|
|
|
|
return ( |
|
37
|
0
|
|
|
0
|
0
|
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
|
|
|
|
|
|
|
sub external_tag_opt_spec { |
|
42
|
|
|
|
|
|
|
return ( |
|
43
|
0
|
|
|
0
|
0
|
0
|
['external-tag:s' => 'Set custom external tag for project. Default value: "source:Serge"'] |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub validate_file_params { |
|
48
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $opt, $args ) = @_; |
|
49
|
0
|
|
|
|
|
0
|
my $rundata = $self->app->{rundata}; |
|
50
|
0
|
0
|
|
|
|
0
|
$rundata->{filetype} = defined $opt->{filetype} ? $opt->{filetype} : '.po'; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub validate_project_id { |
|
54
|
2
|
|
|
2
|
0
|
6
|
my ( $self, $opt, $args ) = @_; |
|
55
|
2
|
|
|
|
|
9
|
my $rundata = $self->app->{rundata}; |
|
56
|
|
|
|
|
|
|
$self->usage_error("'project_id' is required") |
|
57
|
2
|
50
|
|
|
|
16
|
unless defined $opt->{project_id}; |
|
58
|
2
|
|
|
|
|
11
|
$rundata->{project_id} = $opt->{project_id}; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub validate_project_workdir { |
|
62
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $opt, $args ) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
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
|
0
|
|
|
|
0
|
) unless -d $opt->{project_workdir}; |
|
68
|
0
|
|
|
|
|
0
|
$rundata->{project_workdir} = abs_path( $opt->{project_workdir} ); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub validate_args { |
|
72
|
2
|
|
|
2
|
1
|
7
|
my ( $self, $opt, $args ) = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
9
|
my $app = $self->app; |
|
75
|
2
|
|
|
|
|
14
|
my $rundata = $self->app->{rundata}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
2
|
50
|
33
|
|
|
18
|
if ( defined $opt->{token_id} && defined $opt->{token} ) { |
|
78
|
0
|
|
|
|
|
0
|
$app->{config}->{username} = $opt->{token_id}; |
|
79
|
0
|
|
|
|
|
0
|
$app->{config}->{password} = $opt->{token}; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
2
|
50
|
|
|
|
6
|
if ( defined $opt->{base_url} ) { |
|
83
|
0
|
|
|
|
|
0
|
$app->{config}->{base_url} = $opt->{base_url}; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
2
|
100
|
|
|
|
8
|
if ( defined $opt->{log} ) { |
|
87
|
|
|
|
|
|
|
$self->usage_error( |
|
88
|
|
|
|
|
|
|
"directory of 'log', which is set to '$opt->{log}', does not point to a valid directory" |
|
89
|
1
|
50
|
33
|
|
|
68
|
) unless -d dirname( $opt->{log} ) && -w _; |
|
90
|
1
|
|
|
|
|
6
|
$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
|
50
|
33
|
|
|
10
|
&& defined $app->{config}->password ); |
|
98
|
|
|
|
|
|
|
|
|
99
|
2
|
100
|
|
|
|
109
|
$rundata->{debug} = 1 if defined $opt->{debug}; |
|
100
|
|
|
|
|
|
|
|
|
101
|
2
|
|
|
|
|
13
|
$app->init; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |