line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
51221
|
use strict; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
147
|
|
2
|
5
|
|
|
5
|
|
69
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
272
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::App::Command::config; |
5
|
|
|
|
|
|
|
$Footprintless::App::Command::config::VERSION = '1.26'; |
6
|
|
|
|
|
|
|
# ABSTRACT: Prints the config at the coordinate. |
7
|
|
|
|
|
|
|
# PODNAME: Footprintless::App::Command::config |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
31
|
use Footprintless::App -command; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
53
|
|
10
|
5
|
|
|
5
|
|
1842
|
use Log::Any; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
32
|
|
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
|
22
|
my ( $self, $opts, $args ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
3
|
50
|
|
|
|
19
|
my $config = |
53
|
|
|
|
|
|
|
@$args |
54
|
|
|
|
|
|
|
? $self->app()->footprintless()->entities()->get_entity( $args->[0] ) |
55
|
|
|
|
|
|
|
: $self->app()->footprintless()->entities()->as_hashref(); |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
98
|
my $string; |
58
|
3
|
|
50
|
|
|
23
|
my $format = $opts->{format} || 'dumper1'; |
59
|
3
|
|
|
|
|
24
|
$logger->tracef( 'format=%s,config=%s', $format, $config ); |
60
|
3
|
100
|
|
|
|
79
|
if ( $format =~ /^dumper([0-3])?$/ ) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
61
|
2
|
|
|
|
|
18
|
require Data::Dumper; |
62
|
2
|
50
|
|
|
|
8
|
my $indent = defined($1) ? $1 : 1; |
63
|
2
|
|
|
|
|
23
|
$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
|
|
|
|
|
694
|
require JSON; |
71
|
1
|
|
|
|
|
8995
|
my $json = JSON->new(); |
72
|
1
|
50
|
33
|
|
|
37
|
if ( !defined($1) || $1 == 1 || $1 == 3 ) { |
|
|
|
33
|
|
|
|
|
73
|
0
|
|
|
|
|
0
|
$json->pretty(); |
74
|
|
|
|
|
|
|
} |
75
|
1
|
50
|
33
|
|
|
13
|
if ( !defined($1) || $1 == 2 || $1 == 3 ) { |
|
|
|
33
|
|
|
|
|
76
|
1
|
|
|
|
|
12
|
$json->canonical(1); |
77
|
|
|
|
|
|
|
} |
78
|
1
|
|
|
|
|
22
|
$string = $json->encode($config); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
0
|
|
|
|
|
0
|
$self->usage_error("unsupported format [$format]"); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
206
|
print($string); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub opt_spec { |
88
|
3
|
|
|
3
|
1
|
25
|
return ( [ "format|f=s", "format to print", { default => 'dumper1' } ], ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub usage_desc { |
92
|
3
|
|
|
3
|
1
|
207
|
return "fpl config [COORDINATE] %o"; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub validate_args { |
96
|
3
|
|
|
3
|
1
|
2655
|
my ( $self, $opt, $args ) = @_; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |