| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::SimulateReads::CLI::Command; | 
| 2 |  |  |  |  |  |  | # ABSTRACT: App::SimulateReads::CLI subclass for commands interface | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 1 |  |  | 1 |  | 543 | use App::SimulateReads::Base 'class'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 8 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | extends 'App::SimulateReads::CLI'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | our $VERSION = '0.05'; # VERSION | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | override 'opt_spec' => sub { | 
| 11 |  |  |  |  |  |  | super | 
| 12 |  |  |  |  |  |  | }; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  | 0 | 1 |  | sub validate_args { | 
| 15 |  |  |  |  |  |  | # It needs to be override | 
| 16 |  |  |  |  |  |  | } | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  | 0 | 1 |  | sub validate_opts { | 
| 19 |  |  |  |  |  |  | # It needs to be override | 
| 20 |  |  |  |  |  |  | } | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  | 0 | 1 |  | sub execute { | 
| 23 |  |  |  |  |  |  | # It needs to be override | 
| 24 |  |  |  |  |  |  | } | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | sub fill_opts { | 
| 27 | 0 |  |  | 0 | 1 |  | my ($self, $opts, $default_opt) = @_; | 
| 28 | 0 | 0 | 0 |  |  |  | if (ref $opts ne 'HASH' || ref $default_opt ne 'HASH') { | 
| 29 | 0 |  |  |  |  |  | croak '$opts and $default_opt need to be a hash reference'; | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 0 |  |  |  |  |  | for my $opt (keys %$default_opt) { | 
| 33 | 0 | 0 |  |  |  |  | $opts->{$opt} = $default_opt->{$opt} if not exists $opts->{$opt}; | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | __END__ | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =pod | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | =encoding UTF-8 | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | =head1 NAME | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | App::SimulateReads::CLI::Command - App::SimulateReads::CLI subclass for commands interface | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =head1 VERSION | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | version 0.05 | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | extends 'App::SimulateReads::CLI::Command'; | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | This is the base interface to command classes. | 
| 58 |  |  |  |  |  |  | Command classes need to override C<validate_args>, | 
| 59 |  |  |  |  |  |  | C<validate_opts> and C<execute> methods | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =head1 METHODS | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =head2 validate_args | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | This method receives a reference to C<$args> in void | 
| 66 |  |  |  |  |  |  | context. It is expected that the user override it and | 
| 67 |  |  |  |  |  |  | validate the arguments | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | sub validate_args { | 
| 70 |  |  |  |  |  |  | my ($self, $args) = @_ | 
| 71 |  |  |  |  |  |  | ... | 
| 72 |  |  |  |  |  |  | } | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =head2 validate_opts | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | This method receives a reference to C<$opts> in void | 
| 77 |  |  |  |  |  |  | context. It is expected that the user override it and | 
| 78 |  |  |  |  |  |  | validate the options | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | sub validate_opts { | 
| 81 |  |  |  |  |  |  | my ($self, $opts) = @_; | 
| 82 |  |  |  |  |  |  | ... | 
| 83 |  |  |  |  |  |  | } | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =head2 fill_opts | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | This method fills the C<$opts> with default values | 
| 88 |  |  |  |  |  |  | passed by the user. it expects two hash refs | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | $self->fill_opts($opts, \%default_opts); | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =head2 execute | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | This method is called by the application class. It is | 
| 95 |  |  |  |  |  |  | where all the magic occurs. It receives two hash refs | 
| 96 |  |  |  |  |  |  | with C<$opts> and C<$args> in void context | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | sub execute { | 
| 99 |  |  |  |  |  |  | my ($self, $opts, $args) = @_; | 
| 100 |  |  |  |  |  |  | ... | 
| 101 |  |  |  |  |  |  | } | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | =head1 AUTHOR | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | Thiago L. A. Miller <tmiller@mochsl.org.br> | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | This software is Copyright (c) 2017 by Teaching and Research Institute from SÃrio-Libanês Hospital. | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | This is free software, licensed under: | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | The GNU General Public License, Version 3, June 2007 | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | =cut |