/usr/share/perl5/Catmandu/Cmd/info.pm is in libcatmandu-perl 1.0700-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | package Catmandu::Cmd::info;
use Catmandu::Sane;
our $VERSION = '1.07';
use parent 'Catmandu::Cmd';
use Catmandu;
use Catmandu::Util qw(pod_section);
use namespace::clean;
sub command_opt_spec {
(
["all", "show all module on this server"],
["exporters", "show all Catmandu exporters"],
["importers", "show all Catmandu importers"],
["fixes", "show all Catmandu fixes"],
["stores", "show all Catmandu stores"],
["validators", "show all Catmandu validators"],
["namespace=s", "search by namespace"],
["max_depth=i", "maximum depth to search for modules"],
[
"inc=s@",
'override included directories (defaults to @INC)',
{default => [@INC]}
],
["verbose|v", ""],
["fix=s@", ""],
["var=s%", ""],
["preprocess|pp", ""],
);
}
sub _add_about {
my $item = $_[0];
my $name = pod_section($item->{file}, 'NAME');
$name =~ s/[^-]+(\s*-?\s*)?//;
$name =~ s/\n/ /mg;
chomp $name;
$item->{about} = $name;
$item;
}
sub command {
my ($self, $opts, $args) = @_;
my $verbose = $opts->verbose;
if (defined $opts->{namespace}) {
}
elsif ($opts->{all}) {
delete $opts->{all};
}
elsif ($opts->{exporters}) {
delete $opts->{exporters};
$opts->{namespace} = 'Catmandu::Exporter';
}
elsif ($opts->{importers}) {
delete $opts->{importers};
$opts->{namespace} = 'Catmandu::Importer';
}
elsif ($opts->{fixes}) {
delete $opts->{fixes};
$opts->{namespace} = 'Catmandu::Fix';
}
elsif ($opts->{stores}) {
delete $opts->{stores};
$opts->{namespace} = 'Catmandu::Store';
}
elsif ($opts->{validators}) {
delete $opts->{stores};
$opts->{namespace} = 'Catmandu::Validator';
}
else {
$opts->{namespace} = [qw(Catmandu)];
}
my ($from_args, $from_opts, $into_args, $into_opts)
= $self->_parse_options($args);
for my $key (qw(inc namespace max_depth)) {
$from_opts->{$key} = $opts->$key if defined $opts->$key;
}
my $from = Catmandu->importer('Modules', $from_opts)->tap(\&_add_about);
if (@$into_args || %$into_opts) {
if ($opts->fix) {
$from = $self->_build_fixer($opts)->fix($from);
}
my $into = Catmandu->exporter($into_args->[0], $into_opts);
$into->add_many($from);
$into->commit;
}
else {
my $cols = [qw(name version about)];
push @$cols, 'file' if $opts->verbose;
$from->format(cols => $cols);
}
}
1;
__END__
=pod
=head1 NAME
Catmandu::Cmd::info - list installed Catmandu modules
=head1 DESCRIPTION
This L<Catmandu::Cmd> uses L<Catmandu::Importer::Modules> to list all modules.
By default modules are listed in tabular form, like L<Catmandu::Exporter::Table>.
=head1 EXAMPLES
catmandu info --exporters
catmandu info --importers
catmandu info --fixes
catmandu info --stores
catmandu info --validators
catmandu info --namespace=Catmandu
catmandu info --all
# export list of exporter modules to JSON
catmandu info --exporters to JSON
=cut
|