File Coverage

lib/App/Sandy/CLI/Command.pm
Criterion Covered Total %
statement 3 8 37.5
branch 0 4 0.0
condition 0 3 0.0
subroutine 1 5 20.0
pod 4 4 100.0
total 8 24 33.3


line stmt bran cond sub pod time code
1             package App::Sandy::CLI::Command;
2             # ABSTRACT: App::Sandy::CLI subclass for commands interface
3              
4 1     1   560 use App::Sandy::Base 'class';
  1         2  
  1         6  
5              
6             extends 'App::Sandy::CLI';
7              
8             our $VERSION = '0.22'; # 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           die '$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::Sandy::CLI::Command - App::Sandy::CLI subclass for commands interface
46              
47             =head1 VERSION
48              
49             version 0.22
50              
51             =head1 SYNOPSIS
52              
53             extends 'App::Sandy::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 AUTHORS
104              
105             =over 4
106              
107             =item *
108              
109             Thiago L. A. Miller <tmiller@mochsl.org.br>
110              
111             =item *
112              
113             J. Leonel Buzzo <lbuzzo@mochsl.org.br>
114              
115             =item *
116              
117             Felipe R. C. dos Santos <fsantos@mochsl.org.br>
118              
119             =item *
120              
121             Helena B. Conceição <hconceicao@mochsl.org.br>
122              
123             =item *
124              
125             Gabriela Guardia <gguardia@mochsl.org.br>
126              
127             =item *
128              
129             Fernanda Orpinelli <forpinelli@mochsl.org.br>
130              
131             =item *
132              
133             Pedro A. F. Galante <pgalante@mochsl.org.br>
134              
135             =back
136              
137             =head1 COPYRIGHT AND LICENSE
138              
139             This software is Copyright (c) 2018 by Teaching and Research Institute from Sírio-Libanês Hospital.
140              
141             This is free software, licensed under:
142              
143             The GNU General Public License, Version 3, June 2007
144              
145             =cut