App-PMUtils

 view release on metacpan or  search on metacpan

script/pmless  view on Meta::CPAN

#!perl

use 5.010;
use strict;
use warnings;

use App::PMUtils;
use Perinci::CmdLine::Any;

our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
our $DATE = '2024-08-30'; # DATE
our $DIST = 'App-PMUtils'; # DIST
our $VERSION = '0.745'; # VERSION

our %SPEC;
$SPEC{pmless} = {
    v => 1.1,
    summary => 'Show Perl module source code with `less`',
    args => {
        modules => $App::PMUtils::arg_module_multiple,
        pod => {
            schema => 'bool',
            default => 0,
        },
    },
    deps => {
        prog => 'less',
    },
};
sub pmless {
    require Module::Path::More;
    my %args = @_;
    my $mods = $args{modules};
    my @mpaths;
    for my $mod (@$mods) {
        my $mpath = Module::Path::More::module_path(
            module => $mod, find_pmc=>0, find_pod=>$args{pod}, find_prefix=>0);
        if (defined $mpath) {
            push @mpaths, $mpath;
        } else {
            warn "pmless: Can't find path for module '$mod'\n";
        }
    }
    return [404, "Can't find path(s) for module(s)"] unless @mpaths;
    system "less", @mpaths;
    [200, "OK"];
}

Perinci::CmdLine::Any->new(
    url => '/main/pmless',
    read_config => 0,
    read_env => 0,
)->run;

# ABSTRACT: Show Perl module source code with `less`
# PODNAME: pmless

__END__

=pod

=encoding UTF-8

=head1 NAME

pmless - Show Perl module source code with `less`

=head1 VERSION

This document describes version 0.745 of pmless (from Perl distribution App-PMUtils), released on 2024-08-30.

=head1 SYNOPSIS

Basic usage:

 % pmless Some::Module

=head1 OPTIONS

C<*> marks required options.

=head2 Main options

=over

=item B<--modules-json>=I<s>

See C<--modules>.

Can also be specified as the 1st command-line argument and onwards.

=item B<--modules>=I<s@>

(No description)


Can also be specified as the 1st command-line argument and onwards.

Can be specified multiple times.

=item B<--pod>

(No description)



( run in 1.368 second using v1.01-cache-2.11-cpan-39bf76dae61 )