File: Command.pm

package info (click to toggle)
libmoosex-app-perl 1.43-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 4,011; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,282 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# ============================================================================
package MooseX::App::Plugin::Version::Command;
# ============================================================================

use 5.010;
use utf8;

use namespace::autoclean;
use Moose;
use MooseX::App::Command;

command_short_description q(Print the current version);

sub version {
    my ($self,$app) = @_;

    my $version = '';
    $version .= $app->meta->app_base. ' version '.$app->VERSION."\n";
    $version .= "MooseX::App version ".$MooseX::App::VERSION."\n";
    $version .= "Perl version ".sprintf("%vd", $^V);

    my $message_class = $app->meta->app_messageclass;

    my @parts = ($message_class->new({
        header  => 'VERSION',
        body    => MooseX::App::Utils::format_text($version)
    }));

    my %pod_raw = MooseX::App::Utils::parse_pod($app->meta->name);

    foreach my $part ('COPYRIGHT','LICENSE','COPYRIGHT AND LICENSE','AUTHOR','AUTHORS') {
        if (defined $pod_raw{$part}) {
            push(@parts,$message_class->new({
                header  => $part,
                body    => MooseX::App::Utils::format_text($pod_raw{$part}),
            }));
        }
    }

    return MooseX::App::Message::Envelope->new(@parts);
}

__PACKAGE__->meta->make_immutable;
1;