| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Dex; |
|
2
|
5
|
|
|
5
|
|
330909
|
use Moo; |
|
|
5
|
|
|
|
|
68920
|
|
|
|
5
|
|
|
|
|
30
|
|
|
3
|
5
|
|
|
5
|
|
8463
|
use List::Util qw( first ); |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
570
|
|
|
4
|
5
|
|
|
5
|
|
2880
|
use YAML::PP qw( LoadFile ); |
|
|
5
|
|
|
|
|
372647
|
|
|
|
5
|
|
|
|
|
389
|
|
|
5
|
5
|
|
|
5
|
|
2807
|
use IPC::Run3; |
|
|
5
|
|
|
|
|
159865
|
|
|
|
5
|
|
|
|
|
3772
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.002002'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has config_file => ( |
|
10
|
|
|
|
|
|
|
is => 'ro', |
|
11
|
|
|
|
|
|
|
isa => sub { die 'Config file not found' unless $_[0] && -e $_[0] }, |
|
12
|
|
|
|
|
|
|
lazy => 1, |
|
13
|
|
|
|
|
|
|
default => sub { |
|
14
|
|
|
|
|
|
|
first { -e $_ } @{shift->config_file_names}; |
|
15
|
|
|
|
|
|
|
}, |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has config_file_names => ( |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
lazy => 1, |
|
21
|
|
|
|
|
|
|
default => sub { |
|
22
|
|
|
|
|
|
|
return [ qw( dex.yaml .dex.yaml ) ], |
|
23
|
|
|
|
|
|
|
}, |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has config => ( |
|
27
|
|
|
|
|
|
|
is => 'ro', |
|
28
|
|
|
|
|
|
|
lazy => 1, |
|
29
|
|
|
|
|
|
|
builder => sub { |
|
30
|
5
|
|
|
5
|
|
140
|
LoadFile shift->config_file; |
|
31
|
|
|
|
|
|
|
}, |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has menu => ( |
|
35
|
|
|
|
|
|
|
is => 'ro', |
|
36
|
|
|
|
|
|
|
lazy => 1, |
|
37
|
|
|
|
|
|
|
builder => sub { |
|
38
|
4
|
|
|
4
|
|
40296
|
my ( $self ) = @_; |
|
39
|
4
|
|
|
|
|
92
|
return [ $self->_menu_data( $self->config, 0 ) ]; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _menu_data { |
|
44
|
6
|
|
|
6
|
|
63649
|
my ( $self, $config, $depth ) = @_; |
|
45
|
|
|
|
|
|
|
|
|
46
|
6
|
|
|
|
|
13
|
my @menu; |
|
47
|
6
|
|
|
|
|
12
|
foreach my $block ( @{$config} ) { |
|
|
6
|
|
|
|
|
15
|
|
|
48
|
|
|
|
|
|
|
push @menu, { |
|
49
|
|
|
|
|
|
|
name => $block->{name}, |
|
50
|
|
|
|
|
|
|
desc => $block->{desc}, |
|
51
|
10
|
|
|
|
|
40
|
depth => $depth, |
|
52
|
|
|
|
|
|
|
}; |
|
53
|
10
|
100
|
|
|
|
28
|
if ( $block->{children} ) { |
|
54
|
2
|
|
|
|
|
16
|
push @menu, $self->_menu_data($block->{children}, $depth + 1); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
6
|
|
|
|
|
71
|
return @menu; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub display_menu { |
|
62
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $menu ) = @_; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
0
|
$menu = $self->menu unless $menu; |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
0
|
foreach my $item ( @{$menu} ) { |
|
|
0
|
|
|
|
|
0
|
|
|
67
|
0
|
|
|
|
|
0
|
printf( "%s%-24s: %s\n", " " x ( 4 * $item->{depth} ), $item->{name}, $item->{desc} ); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub resolve_block { |
|
72
|
1
|
|
|
1
|
0
|
3486
|
my ( $self, $path ) = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
30
|
return $self->_resolve_block( $path, $self->config ); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _resolve_block { |
|
78
|
1
|
|
|
1
|
|
28996
|
my ( $self, $path, $config ) = @_; |
|
79
|
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
2
|
my $block; |
|
81
|
1
|
|
|
|
|
2
|
while ( defined ( my $segment = shift @{$path} ) ) { |
|
|
3
|
|
|
|
|
12
|
|
|
82
|
2
|
|
|
4
|
|
10
|
$block = first { $_->{name} eq $segment } @{$config}; |
|
|
4
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
10
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
2
|
50
|
|
|
|
10
|
return undef unless $block; |
|
85
|
|
|
|
|
|
|
|
|
86
|
2
|
100
|
|
|
|
26
|
if ( @{$path} ) { |
|
|
2
|
|
|
|
|
7
|
|
|
87
|
1
|
|
|
|
|
3
|
$config = $block->{children}; |
|
88
|
1
|
|
|
|
|
3
|
next; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
1
|
|
|
|
|
28
|
return $block; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub process_block { |
|
95
|
0
|
|
|
0
|
0
|
|
my ( $self, $block ) = @_; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if ( $block->{shell} ) { |
|
98
|
0
|
|
|
|
|
|
_run_block_shell( $block ); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _run_block_shell { |
|
103
|
0
|
|
|
0
|
|
|
my ( $block ) = @_; |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
foreach my $command ( @{$block->{shell}} ) { |
|
|
0
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
run3( $command ); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |