line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
52618
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
134
|
|
2
|
5
|
|
|
5
|
|
59
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
236
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::App::Command::config; |
5
|
|
|
|
|
|
|
$Footprintless::App::Command::config::VERSION = '1.28'; |
6
|
|
|
|
|
|
|
# ABSTRACT: Prints the config at the coordinate. |
7
|
|
|
|
|
|
|
# PODNAME: Footprintless::App::Command::config |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
26
|
use Footprintless::App -command; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
45
|
|
10
|
5
|
|
|
5
|
|
1633
|
use Log::Any; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
28
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $logger = Log::Any->get_logger(); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _entity_to_properties { |
15
|
0
|
|
|
0
|
|
0
|
my ( $entity, $properties, $prefix ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
0
|
|
|
|
0
|
$properties = {} unless $properties; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
my $ref = ref($entity); |
20
|
0
|
0
|
|
|
|
0
|
if ($ref) { |
21
|
0
|
0
|
|
|
|
0
|
if ( $ref eq 'SCALAR' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
$properties->{$prefix} = $$entity; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
elsif ( $ref eq 'ARRAY' ) { |
25
|
0
|
|
|
|
|
0
|
my $index = 0; |
26
|
0
|
|
|
|
|
0
|
foreach my $array_entity ( @{$entity} ) { |
|
0
|
|
|
|
|
0
|
|
27
|
0
|
0
|
|
|
|
0
|
_entity_to_properties( $array_entity, $properties, |
28
|
|
|
|
|
|
|
( $prefix ? "$prefix\[$index\]" : "[$index]" ) ); |
29
|
0
|
|
|
|
|
0
|
$index++; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
elsif ( $ref =~ /^CODE|REF|GLOB|LVALUE|FORMAT|IO|VSTRING|Regexp$/ ) { |
33
|
0
|
|
|
|
|
0
|
croak("unsupported ref type '$ref'"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { # HASH or blessed ref |
36
|
0
|
|
|
|
|
0
|
foreach my $key ( keys( %{$entity} ) ) { |
|
0
|
|
|
|
|
0
|
|
37
|
0
|
0
|
|
|
|
0
|
_entity_to_properties( $entity->{$key}, $properties, |
38
|
|
|
|
|
|
|
( $prefix ? "$prefix.$key" : $key ) ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
0
|
|
|
|
|
0
|
$properties->{$prefix} = $entity; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
return $properties; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub execute { |
50
|
3
|
|
|
3
|
1
|
13
|
my ( $self, $opts, $args ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
3
|
50
|
|
|
|
10
|
my $config = |
53
|
|
|
|
|
|
|
@$args |
54
|
|
|
|
|
|
|
? $self->app()->footprintless()->entities()->get_entity( $args->[0] ) |
55
|
|
|
|
|
|
|
: $self->app()->footprintless()->entities()->as_hashref(); |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
63
|
my $string; |
58
|
3
|
|
50
|
|
|
14
|
my $format = $opts->{format} || 'dumper1'; |
59
|
3
|
|
|
|
|
9
|
$logger->tracef( 'format=%s,config=%s', $format, $config ); |
60
|
3
|
100
|
|
|
|
42
|
if ( $format =~ /^dumper([0-3])?$/ ) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
61
|
2
|
|
|
|
|
8
|
require Data::Dumper; |
62
|
2
|
50
|
|
|
|
7
|
my $indent = defined($1) ? $1 : 1; |
63
|
2
|
|
|
|
|
25
|
$string = Data::Dumper->new( [$config] )->Indent($indent)->Sortkeys(1)->Dump(); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif ( $format eq 'properties' ) { |
66
|
0
|
|
|
|
|
0
|
my $properties = _entity_to_properties($config); |
67
|
0
|
|
|
|
|
0
|
$string = join( "\n", map {"$_=$properties->{$_}"} sort keys( %{$properties} ) ); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ( $format =~ /^json([0-3])?$/ ) { |
70
|
1
|
|
|
|
|
567
|
require JSON; |
71
|
1
|
|
|
|
|
6144
|
my $json = JSON->new(); |
72
|
1
|
50
|
33
|
|
|
13
|
if ( !defined($1) || $1 == 1 || $1 == 3 ) { |
|
|
|
33
|
|
|
|
|
73
|
0
|
|
|
|
|
0
|
$json->pretty(); |
74
|
|
|
|
|
|
|
} |
75
|
1
|
50
|
33
|
|
|
6
|
if ( !defined($1) || $1 == 2 || $1 == 3 ) { |
|
|
|
33
|
|
|
|
|
76
|
1
|
|
|
|
|
5
|
$json->canonical(1); |
77
|
|
|
|
|
|
|
} |
78
|
1
|
|
|
|
|
12
|
$string = $json->encode($config); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
0
|
|
|
|
|
0
|
$self->usage_error("unsupported format [$format]"); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
134
|
print($string); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub opt_spec { |
88
|
3
|
|
|
3
|
1
|
14
|
return ( [ "format|f=s", "format to print", { default => 'dumper1' } ], ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub usage_desc { |
92
|
3
|
|
|
3
|
1
|
116
|
return "fpl config [COORDINATE] %o"; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub validate_args { |
96
|
3
|
|
|
3
|
1
|
1830
|
my ( $self, $opt, $args ) = @_; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |