File Coverage

blib/lib/Ixchel/Actions/install_yq.pm
Criterion Covered Total %
statement 17 27 62.9
branch 0 2 0.0
condition n/a
subroutine 6 10 60.0
pod 2 4 50.0
total 25 43 58.1


line stmt bran cond sub pod time code
1             package Ixchel::Actions::install_yq;
2              
3 1     1   123046 use 5.006;
  1         5  
4 1     1   6 use strict;
  1         2  
  1         33  
5 1     1   4 use warnings;
  1         2  
  1         65  
6 1     1   602 use File::Slurp;
  1         46576  
  1         86  
7 1     1   633 use Ixchel::functions::install_yq;
  1         7  
  1         117  
8 1     1   8 use base 'Ixchel::Actions::base';
  1         2  
  1         43  
9              
10             =head1 NAME
11              
12             Ixchel::Actions::install_yq - Install installs yq
13              
14             =head1 VERSION
15              
16             Version 0.2.0
17              
18             =cut
19              
20             our $VERSION = '0.2.0';
21              
22             =head1 CLI SYNOPSIS
23              
24             ixchel -a install_yq
25              
26             =head1 CODE SYNOPSIS
27              
28             use Data::Dumper;
29              
30             my $results=$ixchel->action(action=>'instal_yq', opts=>{});
31              
32             if ($results->{ok}) {
33             print $results->{status_text};
34             }else{
35             die('Action errored... '.joined("\n", @{$results->{errors}}));
36             }
37              
38             =head1 DESCRIPTION
39              
40             This installs mikefarah/yq. Will use packages if possible, otherwise will
41             grab the binary from github.
42              
43             =head1 FLAGS
44              
45             =head2 -p
46              
47             Where to install it to if not using packages.
48              
49             Default: /usr/bin/yq
50              
51             =head2 -n
52              
53             Don't install via packages.
54              
55             =head1 RESULT HASH REF
56              
57             .errors :: A array of errors encountered.
58             .status_text :: A string description of what was done and the results.
59             .ok :: Set to zero if any of the above errored.
60              
61             =cut
62              
63       0 0   sub new_extra { }
64              
65             sub action_extra {
66 0     0 0   my $self = $_[0];
67              
68 0           $self->status_add( status => 'Installing yq' );
69              
70 0           eval { install_yq( path => $self->{opts}{p}, no_pkg => $self->{opts}{no_pkg} ); };
  0            
71 0 0         if ($@) {
72 0           $self->status_add( status => 'Failed to install yq ... ' . $@, error => 1 );
73             } else {
74 0           $self->status_add( status => 'yq installed' );
75             }
76              
77 0           return undef;
78             } ## end sub action_extra
79              
80             sub short {
81 0     0 1   return 'Install yq.';
82             }
83              
84             sub opts_data {
85 0     0 1   return '
86             p=s
87             no_pkg
88             ';
89             }
90              
91             1;