Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/opt/perl5_14_2/bin/perl | ||
|
||
eval 'exec /opt/perl5_14_2/bin/perl -S $0 ${1+"$@"}' | ||
if 0; # not running under some shell | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Module::Version::App; | ||
|
||
my $app = Module::Version::App->new; | ||
|
||
exit $app->run; | ||
|
||
__END__ | ||
=pod | ||
=head1 NAME | ||
mversion - Program to get module versions | ||
=head1 SYNOPSIS | ||
This program shows you the version of a module or several modules, in a | ||
comfortable manner. | ||
mversion Dancer | ||
mversion --dev --full This That Another | ||
mversion -q -i modules.txt | ||
In Perl-world, we have many ways to determine a version of a module. You can | ||
run C<perl -MModule -le'print $Module::Version'>, but once the name is very long | ||
it becomes tiresome to write. | ||
We can try to load the module in a specific version that is (hopefully) greater | ||
than what we already have installed (if at all). That way we purposely inflict | ||
an error on the compiler and try to read the error msg. C<perl -MModule\ 9999>. | ||
This does not work on multiple modules at once. Some modules even have long | ||
version numbers, such as a date, and then you need to run C<perl | ||
-MModule\ 9999999999> which is seriously annoying. | ||
There are a few modules out there that get you the version number of other | ||
modules but none of them are applications, nor do they have enough options for | ||
comfortable day-to-day usage. This is where C<mversion> comes in. | ||
=head1 OPTIONS | ||
=over 4 | ||
=item -f, --full | ||
This outputs both the name and the version of module, instead of just the | ||
version number. | ||
mversion -f ThisModule ThatModule | ||
mversion --full ThisModule ThatModule | ||
=item -I, --include DIRECTORY, -I MORE, -I EVENMORE | ||
This lets you add any number of directories to include when trying to get a | ||
version number. This is very helpful when you're trying to check if the version | ||
of a module in a specific folder is different than the default one. | ||
# get the version of ThisModule | ||
mversion ThisModule | ||
# get the version of ThisModule from directory dev_releases | ||
mversion -I dev_releases ThisModule | ||
You can include more directories by repeating the flag and argument again. There | ||
is no limit to how many directories you can include. | ||
=item -i, --input FILE | ||
This reads a list of modules from a file. | ||
mversion -i my_modules.txt | ||
mversion --input my_modules.txt | ||
=item -d, --dev | ||
This shows the developer versions (0.01_01) just as that instead of eval()ing | ||
them. | ||
mversion -d Test::More | ||
mversion --dev Test::More | ||
=item -q, --quiet | ||
Usually if a module does not exist, C<mversion> will warn about it. This | ||
allows you to silent those warnings and just carry on. | ||
mversion -q This::Does::Not::Exist But::This::Does | ||
mversion --quiet This::Does::Not::Exist But::This::Does | ||
=back | ||
=head1 SEE ALSO | ||
L<Module::Version> | ||
Github page at L<http://github.com/xsawyerx/module-version>. | ||
=head1 COPYRIGHT | ||
Copyright 2010 Sawyer X. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the terms of either: the GNU General Public License as published | ||
by the Free Software Foundation; or the Artistic License. | ||
See http://dev.perl.org/licenses/ for more information. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package Module::Version; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use base 'Exporter'; | ||
use Carp; | ||
use ExtUtils::MakeMaker; | ||
|
||
our $VERSION = '0.12'; | ||
our @EXPORT_OK = 'get_version'; | ||
|
||
sub get_version { | ||
my $module = shift or croak 'Must get a module name'; | ||
my $file = MM->_installed_file_for_module($module); | ||
|
||
$file || return; | ||
|
||
return MM->parse_version($file) | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
Module::Version - Get module versions | ||
=head1 VERSION | ||
Version 0.12 | ||
=head1 SYNOPSIS | ||
This module fetches the version of any other module. | ||
It comes with a CLI program C<mversion> which does the same. | ||
use Module::Version 'get_version'; | ||
print get_version('Search::GIN'), "\n"; | ||
Or using C<mversion>: | ||
$ mversion Search::GIN | ||
0.04 | ||
$ mversion Doesnt::Exist | ||
Warning: module 'Doesnt::Exist' does not seem to be installed. | ||
$ mversion --quiet Doesnt::Exist | ||
(no output) | ||
$ mversion --full Search::GIN Moose | ||
Search::GIN 0.04 | ||
Moose 1.01 | ||
$ mversion --input modules.txt | ||
Search::GIN 0.04 | ||
Data::Collector 0.03 | ||
Moose 1.01 | ||
=head1 EXPORT | ||
=head2 get_version | ||
C<get_version> will be exported if explicitly specified. | ||
use Module::Version 'get_version'; | ||
B<Nothing> is exported by default. | ||
=head1 SUBROUTINES/METHODS | ||
=head2 get_version | ||
Accepts a module name and fetches the version of the module. | ||
If the module doesn't exist, returns undef. | ||
=head1 AUTHOR | ||
Sawyer X, C<< <xsawyerx at cpan.org> >> | ||
=head1 BUGS | ||
Please report bugs and other issues on the bugtracker: | ||
L<http://github.com/xsawyerx/module-version/issues> | ||
=head1 SUPPORT | ||
This module sports 100% test coverage, but in case you have more issues, please | ||
see I<BUGS> above. | ||
=head1 LICENSE AND COPYRIGHT | ||
Copyright 2010 Sawyer X. | ||
This program is free software; you can redistribute it and/or modify it | ||
under the terms of either: the GNU General Public License as published | ||
by the Free Software Foundation; or the Artistic License. | ||
See http://dev.perl.org/licenses/ for more information. | ||
Oops, something went wrong.