| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | package KiokuDB::Cmd::Base; | ||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | { | ||||||||||
| 7 | package Moose::Meta::Attribute::Custom::Trait::EarlyBuild; | ||||||||||
| 8 | 1 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | } | ||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | BEGIN { local $@; eval "use Time::HiRes qw(time)" }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | extends qw(MooseX::App::Cmd::Command); | |||||||||
| 16 | |||||||||||
| 17 | 1 | with qw(KiokuDB::Cmd::Verbosity); | |||||||||
| 18 | |||||||||||
| 19 | # this is to enable programatic usage: | ||||||||||
| 20 | |||||||||||
| 21 | 1 | has '+usage' => ( required => 0 ); | |||||||||
| 22 | |||||||||||
| 23 | 1 | has '+app' => ( required => 0 ); | |||||||||
| 24 | |||||||||||
| 25 | 1 | has args => ( | |||||||||
| 26 | traits => [qw(NoGetopt)], | ||||||||||
| 27 | isa => "ArrayRef", | ||||||||||
| 28 | is => "ro", | ||||||||||
| 29 | writer => "_args", | ||||||||||
| 30 | predicate => "has_args", | ||||||||||
| 31 | ); | ||||||||||
| 32 | |||||||||||
| 33 | 1 | has exit_code => ( | |||||||||
| 34 | traits => [qw(NoGetopt)], | ||||||||||
| 35 | isa => "Int", | ||||||||||
| 36 | is => "rw", | ||||||||||
| 37 | predicate => "has_exit_code", | ||||||||||
| 38 | ); | ||||||||||
| 39 | |||||||||||
| 40 | 6 | ▶ | sub _build_attrs { | ||||||||
|
Subroutine
_build_attrs: called CC=2 SCAR=6.9
| |||||||||||
| 41 | 6 | my $self = shift; | |||||||||
| 42 | |||||||||||
| 43 | 6 | foreach my $attr ( grep { $_->does("EarlyBuild") } $self->meta->get_all_attributes ) { | |||||||||
| 44 | 15 | $attr->get_value($self); | |||||||||
| 45 | } | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 6 | ▶ | sub run { | ||||||||
|
Subroutine
run: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||
| 49 | 6 | my ( $self, $opts, $args ) = @_; | |||||||||
| 50 | |||||||||||
| 51 | 6 | ▶ | $self->_args($args) if ref $args; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | |||||||||||
| 53 | 6 | $self->_build_attrs; | |||||||||
| 54 | |||||||||||
| 55 | 6 | my $t = -time(); | |||||||||
| 56 | 6 | my $tc = -times; | |||||||||
| 57 | |||||||||||
| 58 | 6 | inner(); | |||||||||
| 59 | |||||||||||
| 60 | 5 | $t += time(); | |||||||||
| 61 | 5 | $tc += times; | |||||||||
| 62 | |||||||||||
| 63 | 5 | $self->v(sprintf "completed in %.2fs (%.2fs cpu)\n", $t, $tc); | |||||||||
| 64 | |||||||||||
| 65 | 5 | ▶ | if ( $self->has_exit_code ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 0 | exit $self->exit_code; | |||||||||
| 67 | } | ||||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 71 | |||||||||||
| 72 | 1 | __PACKAGE__ | |||||||||
| 73 | |||||||||||
| 74 | __END__ | ||||||||||