line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: get project details |
2
|
2
|
|
|
2
|
|
1241
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
82
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Smartcat::App::Command::project; |
6
|
2
|
|
|
2
|
|
10
|
use Smartcat::App -command; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub opt_spec { |
9
|
2
|
|
|
2
|
1
|
30724
|
my ($self) = @_; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
|
|
14
|
my @opts = $self->SUPER::opt_spec; |
12
|
2
|
|
|
|
|
10
|
push @opts, $self->project_id_opt_spec, [ 'list' => 'Get all projects' ]; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
|
|
21
|
return @opts; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub validate_args { |
18
|
2
|
|
|
2
|
1
|
4025
|
my ( $self, $opt, $args ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
15
|
$self->SUPER::validate_args( $opt, $args ); |
21
|
|
|
|
|
|
|
$self->usage_error( |
22
|
|
|
|
|
|
|
"'--list' option cannot be used together with '--project-id'") |
23
|
2
|
50
|
33
|
|
|
11603
|
if ( defined $opt->{list} && defined $opt->{project_id} ); |
24
|
2
|
50
|
|
|
|
26
|
$self->validate_project_id( $opt, $args ) unless defined $opt->{list}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub print_project_details { |
28
|
2
|
|
|
2
|
0
|
5
|
my ( $self, $project ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
10
|
print "Project:\n\t" . $project->name . "\n"; |
31
|
2
|
|
|
|
|
89
|
print "Id:\n\t" . $project->id . "\n"; |
32
|
2
|
|
|
|
|
49
|
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
|
|
|
|
|
26
|
for @{ $project->documents }; |
|
2
|
|
|
|
|
7
|
|
40
|
2
|
|
|
|
|
117
|
print "Target languages:\n"; |
41
|
2
|
|
|
|
|
27
|
print "\t" . join( ' ', @{ $project->target_languages } ) . "\n"; |
|
2
|
|
|
|
|
8
|
|
42
|
2
|
|
|
|
|
46
|
print "Status:\n\t" . $project->status . "\n"; |
43
|
2
|
|
|
|
|
43
|
print "-" x 80; |
44
|
2
|
|
|
|
|
26
|
print "\n"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub print_project { |
48
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $project ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
print "Project:\n\t" . $project->name . "\n"; |
51
|
0
|
|
|
|
|
0
|
print "Id:\n\t" . $project->id . "\n"; |
52
|
0
|
|
|
|
|
0
|
print "Number of documents:\n"; |
53
|
0
|
|
|
|
|
0
|
print "\t" . @{ $project->documents } . "\n"; |
|
0
|
|
|
|
|
0
|
|
54
|
0
|
|
|
|
|
0
|
print "Target languages:\n"; |
55
|
0
|
|
|
|
|
0
|
print "\t" . join( ' ', @{ $project->target_languages } ) . "\n"; |
|
0
|
|
|
|
|
0
|
|
56
|
0
|
|
|
|
|
0
|
print "Status:\n\t" . $project->status . "\n"; |
57
|
0
|
|
|
|
|
0
|
print "-" x 80; |
58
|
0
|
|
|
|
|
0
|
print "\n"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub execute { |
62
|
2
|
|
|
2
|
1
|
16
|
my ( $self, $opt, $args ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
5
|
my $api = $self->app->project_api; |
65
|
2
|
50
|
|
|
|
18
|
if ( defined $opt->{list} ) { |
66
|
0
|
|
|
|
|
0
|
my $projects = $api->get_all_projects; |
67
|
0
|
|
|
|
|
0
|
print "Total number of projects:\n\t" . @$projects . "\n"; |
68
|
0
|
|
|
|
|
0
|
print "-" x 80; |
69
|
0
|
|
|
|
|
0
|
print "\n"; |
70
|
0
|
|
|
|
|
0
|
$self->print_project($_) for @$projects; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
2
|
|
|
|
|
10
|
$self->print_project_details( $api->get_project ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |