| 1 | package Catmandu::Cmd::config; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use Catmandu::Sane; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 13 | our $VERSION = '1.0201_02'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 13 | ▶ | use parent 'Catmandu::Cmd'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use Catmandu::Util qw(data_at); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use Catmandu; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | sub command { | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | my ($self, $opts, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=13 SCAR=31.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | my $path; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | my $into_args = []; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | my $into_opts = {}; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | my $into; | |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | if (@$args == 1 || (@$args > 1 && $args->[1] eq 'to')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@$args == 1 or @$args > 1 and $args->[1] eq "to"
@$args > 1 and $args->[1] eq "to"
MC/DC33%1/3
@$args == 1 or @$args > 1 and $args->[1] eq "to"
@$args == 1
@$args > 1
$args->[1] eq "to"
Truth table50%2/4
A or B and C
A= @$args == 1B= @$args > 1C= $args->[1] eq "to"
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | $path = shift @$args; | |||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | if (@$args && $args->[0] eq 'to') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$args and $args->[0] eq "to"
MC/DC0%0/2
@$args and $args->[0] eq "to"
@$args
$args->[0] eq "to"
Truth table33%1/3
A and B
A= @$argsB= $args->[0] eq "to"
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | for (my $i = 1; $i < @$args; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | my $arg = $args->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | if ($arg =~ s/^-+//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | $arg =~ s/-/_/g; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($arg eq 'fix') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | push @{$into_opts->{$arg} ||= []}, $args->[++$i]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$into_opts->{$arg} ||= []
MC/DC0%0/1
$into_opts->{$arg} ||= []
$into_opts->{$arg}
Truth table0%0/2
A
A= $into_opts->{$arg}
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $into_opts->{$arg} = $args->[++$i]; | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | push @$into_args, $arg; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | if (@$into_args || %$into_opts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$into_args or %$into_opts
MC/DC0%0/2
@$into_args or %$into_opts
@$into_args
%$into_opts
Truth table33%1/3
A or B
A= @$into_argsB= %$into_opts
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | $into = Catmandu->exporter($into_args->[0], $into_opts); | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $into = Catmandu->exporter('JSON', pretty => 1, array => 0); | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | $into->add( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | defined $path ? data_at($path, Catmandu->config) : Catmandu->config); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | $into->commit; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | Catmandu::Cmd::config - export the Catmandu config | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | =head1 EXAMPLES | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | # export config to JSON | ||||||||||||||||||||||||||||||||||||||||||
| 66 | catmandu config | ||||||||||||||||||||||||||||||||||||||||||
| 67 | # or any other Catmandu::Exporter | ||||||||||||||||||||||||||||||||||||||||||
| 68 | catmandu config to YAML --fix 'delete_field(password)' | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # export only part of the config file | ||||||||||||||||||||||||||||||||||||||||||
| 70 | catmandu config my.prefix to CSV | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||||||||||||||||||||||||