line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Cmd::config; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
114286
|
use Catmandu::Sane; |
|
14
|
|
|
|
|
37
|
|
|
14
|
|
|
|
|
86
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
14
|
|
|
14
|
|
106
|
use parent 'Catmandu::Cmd'; |
|
14
|
|
|
|
|
37
|
|
|
14
|
|
|
|
|
74
|
|
8
|
14
|
|
|
14
|
|
6894
|
use Catmandu::Util::Path qw(as_path); |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
824
|
|
9
|
14
|
|
|
14
|
|
100
|
use Catmandu; |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
79
|
|
10
|
14
|
|
|
14
|
|
3408
|
use namespace::clean; |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
65
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub command_opt_spec { |
13
|
3
|
|
|
3
|
1
|
21
|
(["fix=s@", ""], ["var=s%", ""], ["preprocess|pp", ""],); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub command { |
17
|
3
|
|
|
3
|
1
|
8
|
my ($self, $opts, $args) = @_; |
18
|
3
|
|
|
|
|
6
|
my $from; |
19
|
|
|
|
|
|
|
my $into; |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
12
|
my ($from_args, $from_opts, $into_args, $into_opts) |
22
|
|
|
|
|
|
|
= $self->_parse_options($args); |
23
|
|
|
|
|
|
|
|
24
|
3
|
100
|
|
|
|
9
|
if (@$from_args) { |
25
|
1
|
|
|
|
|
6
|
$from = as_path($from_args->[0])->getter->(Catmandu->config); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
2
|
|
|
|
|
11
|
$from = Catmandu->config; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
3
|
50
|
33
|
|
|
28
|
if (@$into_args || %$into_opts) { |
32
|
3
|
|
|
|
|
13
|
$into = Catmandu->exporter($into_args->[0], $into_opts); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
0
|
|
|
|
|
0
|
$into = $self->_default_exporter; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
3
|
100
|
|
|
|
9
|
if ($opts->fix) { |
39
|
1
|
|
|
|
|
11
|
$from = $self->_build_fixer($opts)->fix($from); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
105
|
$into->add($from); |
43
|
3
|
|
|
|
|
57
|
$into->commit; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _default_exporter { |
47
|
0
|
|
|
0
|
|
|
Catmandu->exporter('JSON', pretty => 1, array => 0); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Catmandu::Cmd::config - export the Catmandu config |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 EXAMPLES |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# export config to JSON |
63
|
|
|
|
|
|
|
catmandu config |
64
|
|
|
|
|
|
|
# or any other Catmandu::Exporter |
65
|
|
|
|
|
|
|
catmandu config to YAML --fix 'delete_field(password)' |
66
|
|
|
|
|
|
|
# export only part of the config file |
67
|
|
|
|
|
|
|
catmandu config my.prefix to CSV |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |