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