| 1 | package Mojolicious::Command::version; | ||||||||||
| 2 | 1 | ▶ | use Mojo::Base 'Mojolicious::Command'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use Mojo::IOLoop::Client; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Mojo::IOLoop::TLS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Mojo::JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Mojo::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Mojolicious; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | has description => 'Show versions of available modules'; | |||||||||
| 11 | 1 | ▶ | has usage => sub { shift->extract_usage }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=12 SCAR=27.5
Pod
documented
| |||||||||||
| 14 | 1 | my $self = shift; | |||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | my $json = Mojo::JSON->JSON_XS ? $Cpanel::JSON::XS::VERSION : 'n/a'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 1 | ▶ | my $cryptx = Mojo::Util->CRYPTX ? $CryptX::VERSION : 'n/a'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | ▶ | my $ev = eval { require Mojo::Reactor::EV; 1 } ? $EV::VERSION : 'n/a'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 1 | ▶ | my $socks = Mojo::IOLoop::Client->can_socks ? $IO::Socket::Socks::VERSION : 'n/a'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 1 | ▶ | my $tls = Mojo::IOLoop::TLS->can_tls ? $IO::Socket::SSL::VERSION : 'n/a'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 1 | ▶ | my $nnr = Mojo::IOLoop::Client->can_nnr ? $Net::DNS::Native::VERSION : 'n/a'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 1 | ▶ | my $roles = Mojo::Base->ROLES ? $Role::Tiny::VERSION : 'n/a'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 1 | ▶ | my $async = Mojo::Base->ASYNC ? $Future::AsyncAwait::VERSION : 'n/a'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 1 | print <<EOF; | |||||||||
| 26 | CORE | ||||||||||
| 27 | Perl ($^V, $^O) | ||||||||||
| 28 | Mojolicious ($Mojolicious::VERSION, $Mojolicious::CODENAME) | ||||||||||
| 29 | |||||||||||
| 30 | OPTIONAL | ||||||||||
| 31 | Cpanel::JSON::XS 4.20+ ($json) | ||||||||||
| 32 | CryptX 0.080+ ($cryptx) | ||||||||||
| 33 | EV 4.32+ ($ev) | ||||||||||
| 34 | IO::Socket::Socks 0.64+ ($socks) | ||||||||||
| 35 | IO::Socket::SSL 2.009+ ($tls) | ||||||||||
| 36 | Net::DNS::Native 0.15+ ($nnr) | ||||||||||
| 37 | Role::Tiny 2.000001+ ($roles) | ||||||||||
| 38 | Future::AsyncAwait 0.52+ ($async) | ||||||||||
| 39 | |||||||||||
| 40 | EOF | ||||||||||
| 41 | |||||||||||
| 42 | # Check latest version on CPAN | ||||||||||
| 43 | 1 | ▶ | my $latest = eval { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | $self->app->ua->max_redirects(10) | ||||||||||
| 45 | 1 | ▶ | ->tap(sub { $_->proxy->detect }) | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 46 | ->get('fastapi.metacpan.org/v1/release/Mojolicious') | ||||||||||
| 47 | 1 | ->result->json->{version}; | |||||||||
| 48 | } or return; | ||||||||||
| 49 | |||||||||||
| 50 | 1 | my $msg = 'This version is up to date, have fun!'; | |||||||||
| 51 | 1 | ▶ | $msg = 'Thanks for testing a development release, you are awesome!' if $latest < $Mojolicious::VERSION; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 1 | ▶ | $msg = "You might want to update your Mojolicious to $latest!" if $latest > $Mojolicious::VERSION; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 1 | say $msg; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 1 | 1; | |||||||||
| 57 | |||||||||||
| 58 | =encoding utf8 | ||||||||||
| 59 | |||||||||||
| 60 | =head1 NAME | ||||||||||
| 61 | |||||||||||
| 62 | Mojolicious::Command::version - Version command | ||||||||||
| 63 | |||||||||||
| 64 | =head1 SYNOPSIS | ||||||||||
| 65 | |||||||||||
| 66 | Usage: APPLICATION version [OPTIONS] | ||||||||||
| 67 | |||||||||||
| 68 | mojo version | ||||||||||
| 69 | |||||||||||
| 70 | Options: | ||||||||||
| 71 | -h, --help Show this summary of available options | ||||||||||
| 72 | |||||||||||
| 73 | =head1 DESCRIPTION | ||||||||||
| 74 | |||||||||||
| 75 | L<Mojolicious::Command::version> shows version information for available core and optional modules. | ||||||||||
| 76 | |||||||||||
| 77 | This is a core command, that means it is always enabled and its code a good example for learning to build new commands, | ||||||||||
| 78 | you're welcome to fork it. | ||||||||||
| 79 | |||||||||||
| 80 | See L<Mojolicious::Commands/"COMMANDS"> for a list of commands that are available by default. | ||||||||||
| 81 | |||||||||||
| 82 | =head1 ATTRIBUTES | ||||||||||
| 83 | |||||||||||
| 84 | L<Mojolicious::Command::version> inherits all attributes from L<Mojolicious::Command> and implements the following new | ||||||||||
| 85 | ones. | ||||||||||
| 86 | |||||||||||
| 87 | =head2 description | ||||||||||
| 88 | |||||||||||
| 89 | my $description = $v->description; | ||||||||||
| 90 | $v = $v->description('Foo'); | ||||||||||
| 91 | |||||||||||
| 92 | Short description of this command, used for the command list. | ||||||||||
| 93 | |||||||||||
| 94 | =head2 usage | ||||||||||
| 95 | |||||||||||
| 96 | my $usage = $v->usage; | ||||||||||
| 97 | $v = $v->usage('Foo'); | ||||||||||
| 98 | |||||||||||
| 99 | Usage information for this command, used for the help screen. | ||||||||||
| 100 | |||||||||||
| 101 | =head1 METHODS | ||||||||||
| 102 | |||||||||||
| 103 | L<Mojolicious::Command::version> inherits all methods from L<Mojolicious::Command> and implements the following new | ||||||||||
| 104 | ones. | ||||||||||
| 105 | |||||||||||
| 106 | =head2 run | ||||||||||
| 107 | |||||||||||
| 108 | $v->run(@ARGV); | ||||||||||
| 109 | |||||||||||
| 110 | Run this command. | ||||||||||
| 111 | |||||||||||
| 112 | =head1 SEE ALSO | ||||||||||
| 113 | |||||||||||
| 114 | L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>. | ||||||||||
| 115 | |||||||||||
| 116 | =cut | ||||||||||