| 1 | package Catmandu::Cmd::info; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use Catmandu::Sane; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 14 | our $VERSION = '1.2025'; | |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use parent 'Catmandu::Cmd'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 14 | ▶ | use Catmandu; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 14 | ▶ | use Catmandu::Util qw(pod_section); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | 14 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | sub command_opt_spec { | ||||||||||||||||||||||||||||||||
|
Subroutine
command_opt_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 13 | ( | ||||||||||||||||||||||||||||||||||
| 14 | 7 | ["all", "show all module on this server"], | |||||||||||||||||||||||||||||||||
| 15 | ["exporters", "show all Catmandu exporters"], | ||||||||||||||||||||||||||||||||||
| 16 | ["importers", "show all Catmandu importers"], | ||||||||||||||||||||||||||||||||||
| 17 | ["fixes", "show all Catmandu fixes"], | ||||||||||||||||||||||||||||||||||
| 18 | ["stores", "show all Catmandu stores"], | ||||||||||||||||||||||||||||||||||
| 19 | ["validators", "show all Catmandu validators"], | ||||||||||||||||||||||||||||||||||
| 20 | ["namespace=s", "search by namespace"], | ||||||||||||||||||||||||||||||||||
| 21 | ["max_depth=i", "maximum depth to search for modules"], | ||||||||||||||||||||||||||||||||||
| 22 | [ | ||||||||||||||||||||||||||||||||||
| 23 | "inc=s@", | ||||||||||||||||||||||||||||||||||
| 24 | 'override included directories (defaults to @INC)', | ||||||||||||||||||||||||||||||||||
| 25 | {default => [@INC]} | ||||||||||||||||||||||||||||||||||
| 26 | ], | ||||||||||||||||||||||||||||||||||
| 27 | ["brief", "omit short module description"], | ||||||||||||||||||||||||||||||||||
| 28 | ["verbose|v", ""], | ||||||||||||||||||||||||||||||||||
| 29 | ["fix=s@", ""], | ||||||||||||||||||||||||||||||||||
| 30 | ["var=s%", ""], | ||||||||||||||||||||||||||||||||||
| 31 | ["preprocess|pp", ""], | ||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | 7 | ▶ | sub command { | ||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=15 SCAR=27.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 36 | 7 | my ($self, $opts, $args) = @_; | |||||||||||||||||||||||||||||||||
| 37 | 7 | my $verbose = $opts->verbose; | |||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | 7 | ▶ | if (defined $opts->{namespace}) { | ||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||
| 41 | elsif ($opts->{all}) { | ||||||||||||||||||||||||||||||||||
| 42 | 0 | delete $opts->{all}; | |||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||
| 44 | elsif ($opts->{exporters}) { | ||||||||||||||||||||||||||||||||||
| 45 | 1 | delete $opts->{exporters}; | |||||||||||||||||||||||||||||||||
| 46 | 1 | $opts->{namespace} = 'Catmandu::Exporter'; | |||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||
| 48 | elsif ($opts->{importers}) { | ||||||||||||||||||||||||||||||||||
| 49 | 1 | delete $opts->{importers}; | |||||||||||||||||||||||||||||||||
| 50 | 1 | $opts->{namespace} = 'Catmandu::Importer'; | |||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||
| 52 | elsif ($opts->{fixes}) { | ||||||||||||||||||||||||||||||||||
| 53 | 2 | delete $opts->{fixes}; | |||||||||||||||||||||||||||||||||
| 54 | 2 | $opts->{namespace} = 'Catmandu::Fix'; | |||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||
| 56 | elsif ($opts->{stores}) { | ||||||||||||||||||||||||||||||||||
| 57 | 1 | delete $opts->{stores}; | |||||||||||||||||||||||||||||||||
| 58 | 1 | $opts->{namespace} = 'Catmandu::Store'; | |||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||
| 60 | elsif ($opts->{validators}) { | ||||||||||||||||||||||||||||||||||
| 61 | 1 | delete $opts->{stores}; | |||||||||||||||||||||||||||||||||
| 62 | 1 | $opts->{namespace} = 'Catmandu::Validator'; | |||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||||||||
| 65 | 1 | $opts->{namespace} = [qw(Catmandu)]; | |||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | 7 | my ($from_args, $from_opts, $into_args, $into_opts) | |||||||||||||||||||||||||||||||||
| 69 | = $self->_parse_options($args); | ||||||||||||||||||||||||||||||||||
| 70 | 7 | $from_opts->{about} = !$opts->{brief}; | |||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | 7 | for my $key (qw(inc namespace max_depth)) { | |||||||||||||||||||||||||||||||||
| 73 | 21 | ▶ | $from_opts->{$key} = $opts->$key if defined $opts->$key; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||
| 76 | 7 | my $from = Catmandu->importer('Modules', $from_opts); | |||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | 7 | ▶ | if (@$into_args || %$into_opts) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@$into_args or %$into_opts
MC/DC50%1/2
@$into_args or %$into_opts
@$into_args
%$into_opts
Truth table66%2/3
A or B
A= @$into_argsB= %$into_opts
| |||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | if ($opts->fix) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 80 | 0 | $from = $self->_build_fixer($opts)->fix($from); | |||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | 1 | my $into = Catmandu->exporter($into_args->[0], $into_opts); | |||||||||||||||||||||||||||||||||
| 84 | 1 | $into->add_many($from); | |||||||||||||||||||||||||||||||||
| 85 | 1 | $into->commit; | |||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||
| 87 | else { | ||||||||||||||||||||||||||||||||||
| 88 | 6 | my $cols = [qw(name version)]; | |||||||||||||||||||||||||||||||||
| 89 | 6 | ▶ | push @$cols, 'about' unless $opts->brief; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 90 | 6 | ▶ | push @$cols, 'file' if $opts->verbose; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 91 | 6 | $from->format(cols => $cols); | |||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | 14 | 1; | |||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||
| 97 | __END__ | ||||||||||||||||||||||||||||||||||