line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RL::Command::merge; |
2
|
13
|
|
|
13
|
|
8969
|
use strict; |
|
13
|
|
|
|
|
32
|
|
|
13
|
|
|
|
|
351
|
|
3
|
13
|
|
|
13
|
|
319
|
use warnings; |
|
13
|
|
|
|
|
29
|
|
|
13
|
|
|
|
|
385
|
|
4
|
13
|
|
|
13
|
|
64
|
use autodie; |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
72
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
63998
|
use App::RL -command; |
|
13
|
|
|
|
|
33
|
|
|
13
|
|
|
|
|
140
|
|
7
|
13
|
|
|
13
|
|
4708
|
use App::RL::Common; |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
375
|
|
8
|
|
|
|
|
|
|
|
9
|
13
|
|
|
13
|
|
61
|
use constant abstract => 'merge runlist yaml files'; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
7566
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub opt_spec { |
12
|
4
|
|
|
4
|
1
|
20
|
return ( [ "outfile|o=s", "Output filename. [stdout] for screen." ], { show_defaults => 1, } ); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub usage_desc { |
16
|
4
|
|
|
4
|
1
|
32507
|
return "runlist merge [options] "; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub description { |
20
|
1
|
|
|
1
|
1
|
492
|
my $desc; |
21
|
1
|
|
|
|
|
4
|
$desc .= ucfirst(abstract) . ".\n"; |
22
|
1
|
|
|
|
|
3
|
return $desc; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub validate_args { |
26
|
3
|
|
|
3
|
1
|
1665
|
my ( $self, $opt, $args ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
3
|
100
|
|
|
|
4
|
if ( !@{$args} ) { |
|
3
|
|
|
|
|
11
|
|
29
|
1
|
|
|
|
|
3
|
my $message = "This command need one or more input files.\n\tIt found"; |
30
|
1
|
|
|
|
|
3
|
$message .= sprintf " [%s]", $_ for @{$args}; |
|
1
|
|
|
|
|
3
|
|
31
|
1
|
|
|
|
|
3
|
$message .= ".\n"; |
32
|
1
|
|
|
|
|
9
|
$self->usage_error($message); |
33
|
|
|
|
|
|
|
} |
34
|
2
|
|
|
|
|
5
|
for ( @{$args} ) { |
|
2
|
|
|
|
|
5
|
|
35
|
3
|
50
|
|
|
|
62
|
next if lc $_ eq "stdin"; |
36
|
3
|
100
|
|
|
|
11
|
if ( !Path::Tiny::path($_)->is_file ) { |
37
|
1
|
|
|
|
|
134
|
$self->usage_error("The input file [$_] doesn't exist."); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
1
|
50
|
|
|
|
39
|
if ( !exists $opt->{outfile} ) { |
42
|
0
|
|
|
|
|
0
|
$opt->{outfile} = Path::Tiny::path( $args->[0] )->absolute . ".merge.yml"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub execute { |
47
|
1
|
|
|
1
|
1
|
7
|
my ( $self, $opt, $args ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
2
|
my $out_fh; |
50
|
1
|
50
|
|
|
|
4
|
if ( lc( $opt->{outfile} ) eq "stdout" ) { |
51
|
1
|
|
|
|
|
5
|
$out_fh = *STDOUT; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
0
|
|
|
|
|
0
|
open $out_fh, ">", $opt->{outfile}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
2
|
my $master = {}; |
58
|
1
|
|
|
|
|
3
|
for my $file ( @{$args} ) { |
|
1
|
|
|
|
|
3
|
|
59
|
2
|
|
|
|
|
6
|
my $basename = Path::Tiny::path($file)->basename( ".yaml", ".yml" ); |
60
|
2
|
|
|
|
|
176
|
my $dir = Path::Tiny::path($file)->parent->stringify; |
61
|
2
|
|
|
|
|
161
|
my ($word) = split /[^\w-]+/, $basename; |
62
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
9
|
my $content = YAML::Syck::LoadFile($file); |
64
|
2
|
|
|
|
|
357
|
$master->{$word} = $content; |
65
|
|
|
|
|
|
|
} |
66
|
1
|
|
|
|
|
2
|
print {$out_fh} YAML::Syck::Dump($master); |
|
1
|
|
|
|
|
7
|
|
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
98
|
close $out_fh; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |