blib/lib/Venus/Task/Venus/Run.pm

filter: Statementstmt 94.2% 33 / 35 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 3 / 3 totaltotal 89.8% 44 / 49 CC 3 SCAR 5.5
CC
3
Cov
92%
prepare
3.0
name
2.0
footer
2.0
CRAP 1.7
« blib/lib/Venus/Role/Stashable.pm ↑ Summary blib/lib/Venus/Name.pm »
1 package Venus::Task::Venus::Run;
2  
3 2 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Venus::Class 'attr', 'base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # IMPORTS
11  
12 2 ▶use Venus::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # INHERITS
15  
16 2 base 'Venus::Task::Venus';
17  
18 # REQUIRES
19  
20 2 require Venus;
21  
22 # METHODS
23  
24 0 ▶sub name {
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
25 0 'vns run'
26 }
27  
28 0 ▶sub footer {
Subroutine footer: not called CC=1 SCAR=6.9
Pod documented
29  
30 0 return <<"EOF";
31 Copyright 2022-2023, Vesion $Venus::VERSION, The Venus "AUTHOR" and "CONTRIBUTORS"
32  
33 More information on "vns" and/or the "Venus" standard library, visit
34 https://p3rl.org/vns.
35 EOF
36 }
37  
38 6 ▶sub perform {
Subroutine perform: called CC=1 SCAR=0.0
39 6 my ($self) = @_;
40  
41 6 my $run = Venus::Run->new;
42  
43 6 $run->result(@{$self->data});
44  
45 6 return $self;
46 }
47  
48 8 ▶sub prepare {
Subroutine prepare: called CC=3 SCAR=11.0
Pod documented
49 8 my ($self) = @_;
50  
51 8 $self->summary('execute commands in the Venus configuration file');
52  
53 # name
54 8 $self->argument('name', {
55 name => 'name',
56 help => 'The command to execute.',
57 range => '0',
58 required => 1,
59 type => 'string',
60 wants => 'string',
61 });
62  
63 # args
64 8 $self->argument('args', {
65 name => 'args',
66 help => 'The arguments provide to the command.',
67 range => '1:',
68 multiples => true,
69 type => 'string',
70 wants => 'string',
71 });
72  
73 8 my $config = Venus::Config->read_file($self->file)->value;
74  
75 8 ▶ if ($config->{exec}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"exec"}) 8 0 8
76 8 for my $name (sort keys %{$config->{exec}}) {
77 $self->choice($name, {
78 name => $name,
79 128 help => $config->{exec}->{$name},
80 argument => 'name'
81 });
82 }
83 }
84  
85 # help
86 8 $self->option('help', {
87 name => 'help',
88 help => 'Display the help text.',
89 multiples => 0,
90 required => 0,
91 type => 'boolean',
92 wants => 'boolean',
93 });
94  
95 8 return $self;
96 }
97  
98 2 1;
99  
100  
101 =head1 NAME
102  
103 Venus::Task::Venus::Run - vns run
104  
105 =cut
106  
107 =head1 ABSTRACT
108  
109 Task Class for Venus CLI
110  
111 =cut
112  
113 =head1 SYNOPSIS
114  
115 package main;
116  
117 use Venus::Task::Venus::Run;
118  
119 my $task = Venus::Task::Venus::Run->new;
120  
121 # bless(.., 'Venus::Task::Venus::Run')
122  
123 =cut
124  
125 =head1 DESCRIPTION
126  
127 This package is a task class for the C<vns-run> CLI, and C<vns run>
128 sub-command.
129  
130 =cut
131  
132 =head1 INHERITS
133  
134 This package inherits behaviors from:
135  
136 L<Venus::Task::Venus>
137  
138 =cut
139  
140 =head1 METHODS
141  
142 This package provides the following methods:
143  
144 =cut
145  
146 =head2 new
147  
148 new(any @args) (Venus::Task::Venus::Run)
149  
150 The new method constructs an instance of the package.
151  
152 I<Since C<4.15>>
153  
154 =over 4
155  
156 =item new example 1
157  
158 package main;
159  
160 use Venus::Task::Venus::Run;
161  
162 my $task = Venus::Task::Venus::Run->new;
163  
164 # bless({...}, 'Venus::Task::Venus::Run')
165  
166 =back
167  
168 =cut
169  
170 =head2 perform
171  
172 perform() (Venus::Task::Venus::Run)
173  
174 The perform method executes the CLI logic.
175  
176 I<Since C<4.15>>
177  
178 =over 4
179  
180 =item perform example 1
181  
182 # given: synopsis
183  
184 package main;
185  
186 $task->prepare;
187  
188 my $perform = $task->perform;
189  
190 # bless(.., 'Venus::Task::Venus::Run')
191  
192 =back
193  
194 =over 4
195  
196 =item perform example 2
197  
198 # given: synopsis
199  
200 package main;
201  
202 $task->prepare;
203  
204 $task->parse('brew');
205  
206 my $perform = $task->perform;
207  
208 # bless(.., 'Venus::Task::Venus::Run')
209  
210 # 'perlbrew'
211  
212 =back
213  
214 =over 4
215  
216 =item perform example 3
217  
218 # given: synopsis
219  
220 package main;
221  
222 $task->prepare;
223  
224 $task->parse('cpan', 'Venus');
225  
226 my $perform = $task->perform;
227  
228 # bless(.., 'Venus::Task::Venus::Run')
229  
230 # 'cpanm -llocal -qn Venus'
231  
232 =back
233  
234 =over 4
235  
236 =item perform example 4
237  
238 # given: synopsis
239  
240 package main;
241  
242 $task->prepare;
243  
244 $task->parse('eval', 'say time');
245  
246 my $perform = $task->perform;
247  
248 # bless(.., 'Venus::Task::Venus::Run')
249  
250 # "perl -Ilib -Ilocal/lib/perl5 -MVenus=true,false,log -E 'say time'"
251  
252 =back
253  
254 =over 4
255  
256 =item perform example 5
257  
258 # given: synopsis
259  
260 package main;
261  
262 $task->prepare;
263  
264 $task->parse('lint');
265  
266 my $perform = $task->perform;
267  
268 # bless(.., 'Venus::Task::Venus::Run')
269  
270 # 'perlcritic'
271  
272 =back
273  
274 =over 4
275  
276 =item perform example 6
277  
278 # given: synopsis
279  
280 package main;
281  
282 $task->prepare;
283  
284 $task->parse('docs');
285  
286 my $perform = $task->perform;
287  
288 # bless(.., 'Venus::Task::Venus::Run')
289  
290 # 'perldoc'
291  
292 =back
293  
294 =cut
295  
296 =head1 AUTHORS
297  
298 Awncorp, C<awncorp@cpan.org>
299  
300 =cut
301  
302 =head1 LICENSE
303  
304 Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>.
305  
306 This program is free software, you can redistribute it and/or modify it under
307 the terms of the Apache license version 2.0.
308  
309 =cut
« blib/lib/Venus/Role/Stashable.pm ↑ Summary blib/lib/Venus/Name.pm »