line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RL::Command::some; |
2
|
15
|
|
|
15
|
|
15331
|
use strict; |
|
15
|
|
|
|
|
54
|
|
|
15
|
|
|
|
|
620
|
|
3
|
15
|
|
|
15
|
|
97
|
use warnings; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
561
|
|
4
|
15
|
|
|
15
|
|
101
|
use autodie; |
|
15
|
|
|
|
|
40
|
|
|
15
|
|
|
|
|
126
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
98630
|
use App::RL -command; |
|
15
|
|
|
|
|
41
|
|
|
15
|
|
|
|
|
224
|
|
7
|
15
|
|
|
15
|
|
7295
|
use App::RL::Common; |
|
15
|
|
|
|
|
37
|
|
|
15
|
|
|
|
|
12630
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub abstract { |
10
|
2
|
|
|
2
|
1
|
96
|
return 'extract some records from YAML file'; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub opt_spec { |
14
|
5
|
|
|
5
|
1
|
38
|
return ( [ "outfile|o=s", "output filename. [stdout] for screen" ], { show_defaults => 1, } ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub usage_desc { |
18
|
5
|
|
|
5
|
1
|
57904
|
return "runlist some [options] "; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub description { |
22
|
1
|
|
|
1
|
1
|
645
|
my $desc; |
23
|
1
|
|
|
|
|
5
|
$desc .= ucfirst(abstract) . ".\n"; |
24
|
1
|
|
|
|
|
3
|
return $desc; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub validate_args { |
28
|
4
|
|
|
4
|
1
|
3001
|
my ( $self, $opt, $args ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
4
|
100
|
|
|
|
12
|
if ( @{$args} != 2 ) { |
|
4
|
|
|
|
|
19
|
|
31
|
2
|
|
|
|
|
7
|
my $message = "This command need two input files.\n\tIt found"; |
32
|
2
|
|
|
|
|
4
|
$message .= sprintf " [%s]", $_ for @{$args}; |
|
2
|
|
|
|
|
14
|
|
33
|
2
|
|
|
|
|
6
|
$message .= ".\n"; |
34
|
2
|
|
|
|
|
44
|
$self->usage_error($message); |
35
|
|
|
|
|
|
|
} |
36
|
2
|
|
|
|
|
7
|
for ( @{$args} ) { |
|
2
|
|
|
|
|
8
|
|
37
|
3
|
50
|
|
|
|
126
|
next if lc $_ eq "stdin"; |
38
|
3
|
100
|
|
|
|
18
|
if ( !Path::Tiny::path($_)->is_file ) { |
39
|
1
|
|
|
|
|
129
|
$self->usage_error("The input file [$_] doesn't exist."); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
50
|
|
|
|
87
|
if ( !exists $opt->{outfile} ) { |
44
|
0
|
|
|
|
|
0
|
$opt->{outfile} = Path::Tiny::path( $args->[0] )->absolute . ".list.yml"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub execute { |
49
|
1
|
|
|
1
|
1
|
13
|
my ( $self, $opt, $args ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#----------------------------# |
52
|
|
|
|
|
|
|
# Loading |
53
|
|
|
|
|
|
|
#----------------------------# |
54
|
1
|
|
|
|
|
11
|
my $yml = YAML::Syck::LoadFile( $args->[0] ); |
55
|
1
|
|
|
|
|
504
|
my $all_name_set = Set::Scalar->new; |
56
|
1
|
|
|
|
|
343
|
for my $n ( @{ App::RL::Common::read_names( $args->[1] ) } ) { |
|
1
|
|
|
|
|
11
|
|
57
|
3
|
|
|
|
|
155
|
$all_name_set->insert($n); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
49
|
my $out_ref = {}; |
61
|
1
|
|
|
|
|
2
|
for my $key ( keys %{$yml} ) { |
|
1
|
|
|
|
|
6
|
|
62
|
5
|
100
|
|
|
|
32
|
if ( $all_name_set->has($key) ) { |
63
|
3
|
|
|
|
|
35
|
$out_ref->{$key} = $yml->{$key}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#----------------------------# |
68
|
|
|
|
|
|
|
# Output |
69
|
|
|
|
|
|
|
#----------------------------# |
70
|
1
|
|
|
|
|
4
|
my $out_fh; |
71
|
1
|
50
|
|
|
|
7
|
if ( lc( $opt->{outfile} ) eq "stdout" ) { |
72
|
1
|
|
|
|
|
5
|
$out_fh = *STDOUT; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
0
|
|
|
|
|
0
|
open $out_fh, ">", $opt->{outfile}; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
|
|
2
|
print {$out_fh} YAML::Syck::Dump($out_ref); |
|
1
|
|
|
|
|
7
|
|
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
136
|
close $out_fh; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |