The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

lcpan - Manage your local CPAN mirror

VERSION

This document describes version 0.01 of lcpan (from Perl distribution CPAN-Local), released on 2015-01-13.

SYNOPSIS

Update (download and index) your local CPAN mirror

 % lcpan update

A mini CPAN mirror will be downloaded in your ~/cpan directory. This will take a while (it downloads +- 4GB of files, as of this writing; subsequent update will of course take shorter time.)

A SQLite database is also created/updated in ~/cpan/index.db which contains information about authors, modules/packages, distributions. This database is used for quickly answer various queries.

You can run the above command e.g. daily to keep your mirror up-to-date.

Using your local CPAN mirror to install modules

 % cpanm --mirror ~/cpan --mirror-only -n Some::Module

You can also set up a shell alias to save typing the options all the time, e.g.:

 alias lcpanm="cpanm --mirror ~/cpan --mirror-only -n"

Then you can install modules simply using:

 % lcpanm Some::Module

Querying your local CPAN mirror

Info about your local CPAN mirror:

 % lcpan stats
 +------------------+----------------------+
 | name             | value                |
 +------------------+----------------------+
 | authors          | 11967                |
 | distributions    | 29907                |
 | last-updated     | 2015-01-09T10:40:55Z |
 | modules          | 13365                |
 | packages         | 133650               |
 +------------------+----------------------+

Add --verbose if you want more stats which normally are skipped because they can take a while to get (e.g. disk-space).

List modules:

 % lcpan modules

List modules matching some query (name):

 % lcpan modules smtp

List modules by certain author, show detail instead of just module names:

 % lcpan modules --author PERLANCAR --detail

List modules from a certain dist:

 % lcpan modules --dist libwww-perl --detail

List distributions:

 % lcpan dists

List distributions matching some query (name, filename, abstract), show detail instead of just distribution name:

 % lcpan dists critic --detail

List distributions released by a certain author:

 % lcpan dists --author PERLANCAR

List authors:

 % lcpan authors

List authors matching some query (PAUSE ID, name, email), show detail instead of just ID:

 % lcpan authors tatsuhiko --detail

Show dependencies and reverse dependencies:

 # which modules does Text::ANSITable depend on?
 % lcpan deps Text::ANSITable

 # do it recursively
 % lcpan deps Text::ANSITable -R

 # which distributions depend on Text::ANSITable?
 % lcpan rev-deps Text::ANSITable

DESCRIPTION

This application is a convenient bundling of CPAN::Mini and an indexer so in addition to creating your local CPAN mirror and installing modules from it, you can also query various things about your local CPAN mirror quickly from the command-line (as well as programmatically).

SUBCOMMANDS

authors

List authors in local CPAN.

deps

List dependencies of a module, data from local CPAN.

dists

List distributions in local CPAN.

modules

List packages in local CPAN.

rev-deps

List reverse dependencies of a module, data from local CPAN.

stats

update

update-files

update-index

OPTIONS

* marks required options.

Common options

--config-path=s

Set path to configuration file.

Can be specified multiple times.

--config-profile=s

Set configuration profile to use.

--debug

Set log level to debug.

--format=s

Choose output format, e.g. json, text.

--help, -h, -?

Display this help message.

--json

Set output format to json.

--log-level=s

Set log level.

--naked-res

When outputing as JSON, strip result envelope.

By default, when outputing as JSON, the full enveloped result is returned, e.g.:

    [200,"OK",[1,2,3],{"func.extra"=>4}]

The reason is so you can get the status (1st element), status message (2nd element) as well as result metadata/extra result (4th element) instead of just the result (3rd element). However, sometimes you want just the result, e.g. when you want to pipe the result for more post-processing. In this case you can use `--naked-res` so you just get:

    [1,2,3]
--no-config

Do not use any configuration file.

--quiet

Set log level to quiet.

--subcommands

List available subcommands.

--trace

Set log level to trace.

--verbose

Set log level to info.

--version, -v

Options for subcommand authors

--cpan=s

Location of your local CPAN mirror, e.g. /path/to/cpan.

Defaults to ~/cpan.

--detail
--query=s, -q

Search query.

Options for subcommand deps

--cpan=s

Location of your local CPAN mirror, e.g. /path/to/cpan.

Defaults to ~/cpan.

--include-core

Include Perl core modules.

--level=i, -l

Recurse for a number of levels (-1 means unlimited).

Default value:

 1
--module=s*
--perl-version=s, -V

Set base Perl version for determining core modules.

Default value:

 "v5.18.4"
--phase=s

Default value:

 "runtime"

Valid values:

 ["develop", "configure", "build", "runtime", "test", "ALL"]
--rel=s

Default value:

 "requires"

Valid values:

 ["requires", "recommends", "suggests", "conflicts", "ALL"]
-R

Recurse (alias for `--level -1`).

See --level.

Options for subcommand dists

--author=s, -a

Filter by author.

--cpan=s

Location of your local CPAN mirror, e.g. /path/to/cpan.

Defaults to ~/cpan.

--detail
--query=s, -q

Search query.

Options for subcommand modules

--author=s, -a

Filter by author.

--cpan=s

Location of your local CPAN mirror, e.g. /path/to/cpan.

Defaults to ~/cpan.

--detail
--dist=s, -d

Filter by distribution.

--query=s, -q

Search query.

Options for subcommand rev-deps

--cpan=s

Location of your local CPAN mirror, e.g. /path/to/cpan.

Defaults to ~/cpan.

--module=s*

Options for subcommand stats

--cpan=s

Location of your local CPAN mirror, e.g. /path/to/cpan.

Defaults to ~/cpan.

Options for subcommand update

--cpan=s

Location of your local CPAN mirror, e.g. /path/to/cpan.

Defaults to ~/cpan.

Options for subcommand update-files

--cpan=s

Location of your local CPAN mirror, e.g. /path/to/cpan.

Defaults to ~/cpan.

--max-file-size=i
--remote-url=s

Options for subcommand update-index

--cpan=s

Location of your local CPAN mirror, e.g. /path/to/cpan.

Defaults to ~/cpan.

ENVIRONMENT

LCPAN_OPT

FILES

~/lcpan.conf

/etc/lcpan.conf

FAQ

SEE ALSO

COMPLETION

This script has shell tab completion capability with support for several shells.

bash

To activate bash completion for this script, put:

 complete -C lcpan lcpan

in your bash startup (e.g. ~/.bashrc). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.

It is recommended, however, that you install shcompgen which allows you to activate completion scripts for several kinds of scripts on multiple shells. Some CPAN distributions (those that are built with Dist::Zilla::Plugin::GenShellCompletion) will even automatically enable shell completion for their included scripts (using shcompgen) at installation time, so you can immadiately have tab completion.

tcsh

To activate tcsh completion for this script, put:

 complete lcpan 'p/*/`lcpan`/'

in your tcsh startup (e.g. ~/.tcshrc). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.

It is also recommended to install shcompgen (see above).

other shells

For fish and zsh, install shcompgen as described above.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/CPAN-Local.

SOURCE

Source repository is at https://github.com/perlancar/perl-CPAN-Local.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Local

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.