| 1 | package App::PericmdUtils; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||
| 8 | 1 | our $DATE = '2022-05-27'; # DATE | |||||||||
| 9 | 1 | our $DIST = 'App-PericmdUtils'; # DIST | |||||||||
| 10 | 1 | our $VERSION = '0.054'; # VERSION | |||||||||
| 11 | |||||||||||
| 12 | 1 | our %SPEC; | |||||||||
| 13 | |||||||||||
| 14 | $SPEC{list_pericmd_plugins} = { | ||||||||||
| 15 | 1 | v => 1.1, | |||||||||
| 16 | summary => "List Perinci::CmdLine plugins", | ||||||||||
| 17 | description => <<'_', | ||||||||||
| 18 | |||||||||||
| 19 | This utility lists Perl modules in the `Perinci::CmdLine::Plugin::*` namespace. | ||||||||||
| 20 | |||||||||||
| 21 | _ | ||||||||||
| 22 | args => { | ||||||||||
| 23 | # XXX use common library | ||||||||||
| 24 | detail => { | ||||||||||
| 25 | schema => 'bool*', | ||||||||||
| 26 | cmdline_aliases => {l=>{}}, | ||||||||||
| 27 | }, | ||||||||||
| 28 | }, | ||||||||||
| 29 | examples => [ | ||||||||||
| 30 | {argv=>[]}, | ||||||||||
| 31 | {argv=>['-l'], summary=>'Show details'}, | ||||||||||
| 32 | ], | ||||||||||
| 33 | }; | ||||||||||
| 34 | 0 | ▶ | sub list_pericmd_plugins { | ||||||||
|
Subroutine
list_pericmd_plugins: not called CC=4 SCAR=28.0
Pod
documented
| |||||||||||
| 35 | 0 | require Module::List::Tiny; | |||||||||
| 36 | 0 | my %args = @_; | |||||||||
| 37 | |||||||||||
| 38 | 0 | my $mods = Module::List::Tiny::list_modules( | |||||||||
| 39 | "Perinci::CmdLine::Plugin::", | ||||||||||
| 40 | {list_modules => 1, recurse=>1}, | ||||||||||
| 41 | ); | ||||||||||
| 42 | |||||||||||
| 43 | 0 | my @rows; | |||||||||
| 44 | 0 | for my $mod (sort keys %$mods) { | |||||||||
| 45 | 0 | my $name = $mod; $name =~ s/^Perinci::CmdLine::Plugin:://; | |||||||||
| 46 | 0 | my $row = {name => $name}; | |||||||||
| 47 | 0 | ▶ | if ($args{detail}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | #require Module::Abstract; | ||||||||||
| 49 | #$row->{abstract} = Module::Abstract::module_abstract($mod); | ||||||||||
| 50 | |||||||||||
| 51 | 0 | (my $modpm = "$mod.pm") =~ s!::!/!g; | |||||||||
| 52 | 0 | require $modpm; | |||||||||
| 53 | 0 | my $meta = $mod->meta; | |||||||||
| 54 | 0 | $row->{summary} = $meta->{summary}; | |||||||||
| 55 | 0 | $row->{conf} = join(", ", sort keys %{$meta->{conf}}); | |||||||||
| 56 | 0 | $row->{tags} = join(", ", @{$meta->{tags}}); | |||||||||
| 57 | |||||||||||
| 58 | 0 | require Package::Stash; | |||||||||
| 59 | 0 | my $stash = Package::Stash->new($mod); | |||||||||
| 60 | 0 | $row->{hooks} = join(", ", (grep /^(on_|after_|before_)/, $stash->list_all_symbols('CODE'))); | |||||||||
| 61 | |||||||||||
| 62 | { | ||||||||||
| 63 | 0 | ▶ | no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||
| 64 | 0 | $row->{dist} = ${"$mod\::DIST"}; | |||||||||
| 65 | } | ||||||||||
| 66 | } | ||||||||||
| 67 | 0 | push @rows, $row; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 0 | my %resmeta; | |||||||||
| 71 | 0 | ▶ | if ($args{detail}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 0 | $resmeta{'table.fields'} = ['name', 'summary']; | |||||||||
| 73 | } else { | ||||||||||
| 74 | 0 | @rows = map { $_->{name} } @rows; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 0 | [200, "OK", \@rows, \%resmeta]; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 1 | 1; | |||||||||
| 81 | # ABSTRACT: Some utilities related to Perinci::CmdLine | ||||||||||
| 82 | |||||||||||
| 83 | __END__ | ||||||||||