File Coverage

blib/lib/Ixchel/Actions/systemd_auto_list.pm
Criterion Covered Total %
statement 11 22 50.0
branch 0 4 0.0
condition n/a
subroutine 4 8 50.0
pod 2 4 50.0
total 17 38 44.7


line stmt bran cond sub pod time code
1             package Ixchel::Actions::systemd_auto_list;
2              
3 1     1   114814 use 5.006;
  1         4  
4 1     1   8 use strict;
  1         2  
  1         60  
5 1     1   9 use warnings;
  1         2  
  1         86  
6 1     1   8 use base 'Ixchel::Actions::base';
  1         1  
  1         629  
7              
8             =head1 NAME
9              
10             Ixchel::Actions::systemd_auto_list - List systemd auto generated services.
11              
12             =head1 VERSION
13              
14             Version 0.2.0
15              
16             =cut
17              
18             our $VERSION = '0.2.0';
19              
20             =head1 CLI SYNOPSIS
21              
22             ixchel -a
23              
24             =head1 CODE SYNOPSIS
25              
26             use Data::Dumper;
27              
28             my $results=$ixchel->action(action=>'systemd_auto_list', opts=>{np=>1}, );
29              
30             if ($results->{ok}) {
31             print 'Service: '.joined(', ', @{ $results->{services} })."\n";
32             }else{
33             die('Action errored... '.joined("\n", @{$results->{errors}}));
34             }
35              
36             =head1 DESCRIPTION
37              
38             Returns configured automatically generated systemd units.
39              
40             =head1 SWITCHES
41              
42             =head2 --np
43              
44             Do not print anything. For use if calling this directly instead of via the cli tool.
45              
46             =head1 RESULT HASH REF
47              
48             .errors :: A array of errors encountered.
49             .status_text :: A string description of what was done and the results.
50             .ok :: Set to zero if any of the above errored.
51             .services :: A array of services.
52              
53             =cut
54              
55       0 0   sub new_extra { }
56              
57             sub action_extra {
58 0     0 0   my $self = $_[0];
59              
60 0           my @services = keys( %{ $self->{config}{systemd}{auto} } );
  0            
61              
62 0 0         if ( !$self->{opts}{np} ) {
63 0           print join( "\n", @services );
64 0 0         if ( defined( $services[0] ) ) {
65 0           print "\n";
66             }
67             }
68              
69 0           $self->{results}{services} = \@services;
70              
71 0           return undef;
72             } ## end sub action_extra
73              
74             sub short {
75 0     0 1   return 'List systemd auto generated services.';
76             }
77              
78             sub opts_data {
79 0     0 1   return 'np
80             ';
81             }
82              
83             1;