line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RL::Command::split; |
2
|
14
|
|
|
14
|
|
8696
|
use strict; |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
397
|
|
3
|
14
|
|
|
14
|
|
70
|
use warnings; |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
319
|
|
4
|
14
|
|
|
14
|
|
67
|
use autodie; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
77
|
|
5
|
|
|
|
|
|
|
|
6
|
14
|
|
|
14
|
|
70088
|
use App::RL -command; |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
132
|
|
7
|
14
|
|
|
14
|
|
4629
|
use App::RL::Common; |
|
14
|
|
|
|
|
33
|
|
|
14
|
|
|
|
|
353
|
|
8
|
|
|
|
|
|
|
|
9
|
14
|
|
|
14
|
|
69
|
use constant abstract => 'split runlist yaml files'; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
6613
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub opt_spec { |
12
|
|
|
|
|
|
|
return ( |
13
|
4
|
|
|
4
|
1
|
26
|
[ "outdir|o=s", "output location, [stdout] for screen", { default => '.' } ], |
14
|
|
|
|
|
|
|
[ "suffix|s=s", "extension of output files,", { default => '.yml' } ], |
15
|
|
|
|
|
|
|
{ show_defaults => 1, } |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub usage_desc { |
20
|
4
|
|
|
4
|
1
|
33067
|
return "runlist split [options] "; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub description { |
24
|
1
|
|
|
1
|
1
|
680
|
my $desc; |
25
|
1
|
|
|
|
|
3
|
$desc .= ucfirst(abstract) . ".\n"; |
26
|
1
|
|
|
|
|
3
|
return $desc; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub validate_args { |
30
|
3
|
|
|
3
|
1
|
2177
|
my ( $self, $opt, $args ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
3
|
100
|
|
|
|
5
|
if ( @{$args} != 1 ) { |
|
3
|
|
|
|
|
12
|
|
33
|
1
|
|
|
|
|
3
|
my $message = "This command need one input file.\n\tIt found"; |
34
|
1
|
|
|
|
|
2
|
$message .= sprintf " [%s]", $_ for @{$args}; |
|
1
|
|
|
|
|
3
|
|
35
|
1
|
|
|
|
|
8
|
$message .= ".\n"; |
36
|
1
|
|
|
|
|
8
|
$self->usage_error($message); |
37
|
|
|
|
|
|
|
} |
38
|
2
|
|
|
|
|
3
|
for ( @{$args} ) { |
|
2
|
|
|
|
|
5
|
|
39
|
2
|
50
|
|
|
|
7
|
next if lc $_ eq "stdin"; |
40
|
2
|
100
|
|
|
|
8
|
if ( !Path::Tiny::path($_)->is_file ) { |
41
|
1
|
|
|
|
|
97
|
$self->usage_error("The input file [$_] doesn't exist."); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
56
|
if ( !exists $opt->{outdir} ) { |
46
|
0
|
|
|
|
|
0
|
$opt->{outdir} = Path::Tiny::path( $args->[0] )->absolute . ".split"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub execute { |
51
|
1
|
|
|
1
|
1
|
7
|
my ( $self, $opt, $args ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
6
|
my $yml = YAML::Syck::LoadFile( $args->[0] ); |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
283
|
for my $key ( keys %{$yml} ) { |
|
1
|
|
|
|
|
6
|
|
56
|
16
|
50
|
|
|
|
390
|
if ( lc( $opt->{outdir} ) eq "stdout" ) { |
57
|
16
|
|
|
|
|
37
|
print YAML::Syck::Dump( $yml->{$key} ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
|
|
|
|
|
|
YAML::Syck::DumpFile( Path::Tiny::path( $opt->{outdir}, $key . $opt->{suffix} ), |
61
|
0
|
|
|
|
|
|
$yml->{$key} ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |