p5-p5u / lib / P5U / Command /

package P5U::Command::Version;

use 5.010;
use strict;
use utf8;
use P5U-command;

use PerlX::Maybe 0 'maybe';

	$P5U::Command::Version::AUTHORITY = 'cpan:TOBYINK';
	$P5U::Command::Version::VERSION   = '0.007';

use constant {
	abstract    => q[show the version number of a module],
	usage_desc  => q[%c version %o Module],

sub command_names

sub description
This command is inspired by Given one or more module names, it
locates the modules on your local system and tells you the version
number. (Note that you may have multiple versions of a module installed
in different locations.)

	p5u v MooseX::Types MouseX::Types

Unlike, it also has the ability to reach out to CPAN/BackPAN and find
versions of the module available there:

	p5u v -c MooseX::Types
	p5u v -b MooseX::Types

You can even combine options:

	p5u v -lcb MooseX::Types
	p5u v -lc MooseX::Types MouseX::Types

If no options are provided, defaults to "--local".

sub opt_spec
	return (
		['cpan|c'     => 'search CPAN'],
		['local|l'    => 'search @INC'],
		['backpan|b'  => 'search BackPAN'],

sub execute
	my ($self, $opt, $args) = @_;

	$opt->{local}++ unless $opt->{cpan} || $opt->{backpan};
	$self->usage_error("You must provide a module name.")
		unless @$args;
	require P5U::Lib::Version;
	my $helper = 'P5U::Lib::Version';
	while (my $m = shift @$args)
		say $m;
		my @lines;
		push @lines, $helper->local_module_info($m)   if $opt->{local};
		push @lines, $helper->cpan_module_info($m)    if $opt->{cpan};
		push @lines, $helper->backpan_module_info($m) if $opt->{backpan};
		push @lines, q(Not found) unless @lines;
		say "\t$_" for @lines;
		say q() if @$args; 

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.