line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shipwright::Script; |
2
|
2
|
|
|
2
|
|
49093
|
use strict; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
47
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
40
|
|
4
|
2
|
|
|
2
|
|
502
|
use App::CLI; |
|
2
|
|
|
|
|
46975
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
299
|
use Shipwright::Util; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
188
|
|
6
|
2
|
|
|
2
|
|
13
|
use base qw/App::CLI Shipwright::Base/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
899
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/repository log_file log_level/); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head2 alias |
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub alias { |
14
|
|
|
|
|
|
|
return ( |
15
|
9
|
|
|
9
|
1
|
4158
|
ls => 'list', |
16
|
|
|
|
|
|
|
del => 'delete', |
17
|
|
|
|
|
|
|
up => 'update', |
18
|
|
|
|
|
|
|
init => 'create', |
19
|
|
|
|
|
|
|
initialize => 'create', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 global_options |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub global_options { |
28
|
|
|
|
|
|
|
( |
29
|
9
|
|
|
9
|
1
|
73
|
'r|repository=s' => 'repository', |
30
|
|
|
|
|
|
|
'l|log-level=s' => 'log_level', |
31
|
|
|
|
|
|
|
'log-file=s' => 'log_file', |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 prepare |
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub prepare { |
39
|
9
|
|
|
9
|
1
|
5055
|
my $self = shift; |
40
|
9
|
100
|
|
|
|
25
|
$ARGV[0] = 'help' unless @ARGV; |
41
|
|
|
|
|
|
|
|
42
|
9
|
100
|
|
|
|
50
|
if ( $ARGV[0] =~ /--?h(elp)?/i ) { |
|
|
50
|
|
|
|
|
|
43
|
2
|
|
|
|
|
4
|
$ARGV[0] = 'help'; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif ( $ARGV[0] =~ /^(-v|--version|version)$/ ) { |
46
|
0
|
|
|
|
|
0
|
print( "This is Shipwright, version $Shipwright::VERSION" . "\n" ); |
47
|
0
|
|
|
|
|
0
|
exit 0; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
9
|
|
|
|
|
12
|
my $action = $ARGV[0]; |
51
|
|
|
|
|
|
|
|
52
|
9
|
|
|
|
|
34
|
my $cmd = $self->SUPER::prepare(@_); |
53
|
|
|
|
|
|
|
|
54
|
6
|
100
|
|
|
|
2113
|
unless ( ref $cmd eq 'Shipwright::Script::Help' ) { |
55
|
|
|
|
|
|
|
$cmd->repository( $ENV{SHIPWRIGHT_SHIPYARD} ) |
56
|
3
|
50
|
66
|
|
|
20
|
if !$cmd->repository && $ENV{SHIPWRIGHT_SHIPYARD}; |
57
|
|
|
|
|
|
|
$cmd->repository( $ENV{SHIPWRIGHT_REPOSITORY} ) |
58
|
3
|
50
|
66
|
|
|
15
|
if !$cmd->repository && $ENV{SHIPWRIGHT_REPOSITORY}; |
59
|
3
|
100
|
|
|
|
7
|
if ( $cmd->repository ) { |
60
|
2
|
|
|
|
|
267
|
require Shipwright::Backend; |
61
|
2
|
|
|
|
|
17
|
my $backend = Shipwright::Backend->new( |
62
|
|
|
|
|
|
|
repository => $cmd->repository, |
63
|
|
|
|
|
|
|
no_sync_local_dir => 1, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# this $shipwright object will do nothing, except for init logging |
67
|
0
|
|
|
|
|
0
|
my $shipwright = Shipwright->new( |
68
|
|
|
|
|
|
|
repository => $cmd->repository, |
69
|
|
|
|
|
|
|
log_level => $cmd->log_level, |
70
|
|
|
|
|
|
|
log_file => $cmd->log_file, |
71
|
|
|
|
|
|
|
); |
72
|
0
|
0
|
|
|
|
0
|
confess_or_die 'invalid repository: ' |
|
|
0
|
|
|
|
|
|
73
|
|
|
|
|
|
|
. $cmd->repository |
74
|
|
|
|
|
|
|
unless $backend->check_repository( |
75
|
|
|
|
|
|
|
action => $action, |
76
|
|
|
|
|
|
|
$action eq 'create' ? ( force => $cmd->force ) : () |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
else { |
80
|
1
|
|
|
|
|
3
|
confess_or_die "need repository arg\n"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
3
|
|
|
|
|
9
|
return $cmd; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 log |
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub log { |
90
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# init logging is done in prepare, no need to init here, just returns logger |
93
|
1
|
|
|
|
|
7
|
return Log::Log4perl->get_logger( ref $self ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |