blib/lib/Venus/Run.pm untested

filter: Statementstmt 0.0% 0 / 293 Branchbran 0.0% 0 / 140 Conditioncond 0.0% 0 / 32 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 51 Podpod 0.0% 0 / 37 totaltotal 0.0% 0 / 553 SCAR 85.4
CC
71
Cov
0%
_find
110.0
_prep
110.0
_set_conf
30.0
CRAP 5112.0
1 package Venus::Run;
2  
3 use 5.018;
4  
5 use strict;
6 use warnings;
7  
8 use Venus::Class 'base';
9  
10 base 'Venus::Task';
11  
12 use Venus;
13  
14 our $NAME = __PACKAGE__;
15  
16 # HOOKS
17  
18 sub _print {
19 do {local $| = 1; CORE::print(@_, "\n")}
20 }
21  
22 sub _prompt {
23 do {local $\ = ''; local $_ = <STDIN>; chomp; $_}
24 }
25  
26 # METHODS
27  
28 state $args = {
29 'command' => {
30 help => 'Command to run',
31 required => 1,
32 }
33 };
34  
35 sub args {
36  
37 return $args;
38 }
39  
40 state $cmds = {
41 'help' => {
42 help => 'Display help and usages',
43 arg => 'command',
44 },
45 'init' => {
46 help => 'Initialize the configuration file',
47 arg => 'command',
48 },
49 };
50  
51 sub cmds {
52  
53 return $cmds;
54 }
55  
56 sub conf {
57 my ($self) = @_;
58  
59 require Venus::Config;
60  
61 return Venus::Config->read_file($self->file)->value;
62 }
63  
64 sub file {
65  
66 return $ENV{VENUS_FILE} || (grep -f, map ".vns.$_", qw(yaml yml json js perl pl))[0]
67 }
68  
69 state $footer = <<"EOF";
70 Config:
71  
72 Here is an example configuration in YAML (e.g. in .vns.yaml).
73  
74 ---
75 data:
76 ECHO: true
77 exec:
78 cpan: cpanm -llocal -qn
79 deps: cpan --installdeps .
80 each: \$PERL -MVenus=log -nE
81 exec: \$PERL -MVenus=log -E
82 okay: \$PERL -c
83 repl: \$PERL -dE0
84 says: exec "map log(eval), \@ARGV"
85 test: \$PROVE
86 libs:
87 - -Ilib
88 - -Ilocal/lib/perl5
89 path:
90 - bin
91 - dev
92 - local/bin
93 perl:
94 perl: perl
95 prove: prove
96 vars:
97 PERL: perl
98 PROVE: prove
99  
100 Examples:
101  
102 Here are examples usages using the example YAML configuration.
103  
104 # Mint a new configuration file
105 vns init
106  
107 # Install a distribution
108 vns cpan \$DIST
109  
110 # Install dependencies in the CWD
111 vns deps
112  
113 # Check that a package can be compiled
114 vns okay \$FILE
115  
116 # Use the Perl debugger as a REPL
117 vns repl
118  
119 # Evaluate arbitrary Perl expressions
120 vns exec ...
121  
122 # Test the Perl project in the CWD
123 vns test t
124  
125 Copyright 2022-2023, Vesion $Venus::VERSION, The Venus "AUTHOR" and "CONTRIBUTORS"
126  
127 More information on "vns" and/or the "Venus" standard library, visit
128 https://p3rl.org/vns.
129 EOF
130  
131 sub footer {
132  
133 return $footer;
134 }
135  
136 sub handler {
137 my ($self, $data) = @_;
138  
139 my $help = $data->{help};
140 my $next = $data->{command};
141  
142 return $self->okay if !$help && !$next;
143  
144 return $self->handler_for_help($data) if (!$next && $help) || (lc($next) eq 'help');
145  
146 return $self->handler_for_init($data) if lc($next) eq 'init';
147  
148 return $self->handler_for_exec($data);
149 }
150  
151 sub handler_for_exec {
152 my ($self, $data) = @_;
153  
154 my $code = sub {
155 my $command = _vars(join ' ', @_);
156  
157 $self->log_info('Using:', $command) if $ENV{ECHO};
158  
159 my $error = $self->catch('system', $command);
160  
161 $self->log_error("Error running command! $command") if $ENV{ECHO} && $error;
162  
163 return $error ? false : true;
164 };
165  
166 return $self->exit(undef, sub{_exec($code, $self->conf, @{$self->data})});
167 }
168  
169 sub handler_for_help {
170 my ($self, $data) = @_;
171  
172 my $conf = $self->conf;
173 my $type = $self->data->[1];
174  
175 if (exists $conf->{help} && exists $conf->{help}{$type}) {
176 return $self->fail(sub{$self->log_info($conf->{help}{$type})})
177 }
178 else {
179 return $self->fail(sub{$self->log_info($self->help)});
180 }
181 }
182  
183 sub handler_for_init {
184 my ($self, $data) = @_;
185  
186 my $file = $self->file;
187  
188 return $self->fail('log_error', "Already using $file") if $file && -f $file;
189  
190 $file ||= '.vns.pl';
191  
192 require Venus::Config;
193  
194 my $init = $self->init;
195  
196 Venus::Config->new($self->init)->write_file($file);
197  
198 return $self->okay('log_info', "Initialized with generated file $file");
199 }
200  
201 state $init = {
202 data => {
203 ECHO => 1,
204 },
205 exec => {
206 brew => 'perlbrew',
207 cpan => 'cpanm -llocal -qn',
208 docs => 'perldoc',
209 each => 'shim -nE',
210 edit => '$EDITOR $VENUS_FILE',
211 eval => 'shim -E',
212 exec => '$PERL',
213 info => '$PERL -V',
214 lint => 'perlcritic',
215 okay => '$PERL -c',
216 repl => '$REPL',
217 reup => 'cpanm -qn Venus',
218 says => 'eval "map log(eval), @ARGV"',
219 shim => '$PERL -MVenus=true,false,log',
220 test => '$PROVE',
221 tidy => 'perltidy',
222 },
223 libs => [
224 '-Ilib',
225 '-Ilocal/lib/perl5',
226 ],
227 path => [
228 'bin',
229 'dev',
230 'local/bin',
231 ],
232 perl => {
233 perl => 'perl',
234 prove => 'prove',
235 },
236 vars => {
237 PERL => 'perl',
238 PROVE => 'prove',
239 REPL => '$PERL -dE0',
240 },
241 };
242  
243 sub init {
244  
245 return $init;
246 }
247  
248 sub name {
249  
250 return $ENV{VENUS_TASK_NAME} || $NAME;
251 }
252  
253 state $opts = {
254 'help' => {
255 help => 'Show help information',
256 }
257 };
258  
259 sub opts {
260  
261 return $opts;
262 }
263  
264 # ROUTINES
265  
266 sub _exec {
267 my ($code, $conf, @data) = @_;
268  
269 return () if !@data;
270  
271 $conf = _set_conf($conf);
272  
273 my %ORIG_ENV = %ENV;
274  
275 _set_vars($conf);
276  
277 _set_path($conf);
278  
279 _set_libs($conf);
280  
281 _set_vars($conf);
282  
283 my $result;
284  
285 for my $step (_flow($conf, @data)) {
286 my ($prog, @args) = @{$step};
287  
288 ($result = $code->($prog, @args)) ? next : last if $prog;
289 }
290  
291 %ENV = %ORIG_ENV;
292  
293 return $result;
294 }
295  
296 sub _find {
297 my ($seen, $conf, @data) = @_;
298  
299 return () if !@data;
300  
301 @data = map _split($_), @data;
302  
303 my @item = shift @data;
304  
305 @item = (_find_in_exec($seen, $conf, @item));
306  
307 if (@item > 1) {
308 unshift @data, @item; @item = shift @data;
309 }
310  
311 @item = (_find_in_find($seen, $conf, @item));
312  
313 if (@item > 1) {
314 unshift @data, @item; @item = shift @data;
315 }
316  
317 @item = (_find_in_flow($seen, $conf, @item));
318  
319 if (@item > 1) {
320 unshift @data, @item; @item = shift @data;
321 }
322  
323 @item = (_find_in_func($seen, $conf, @item));
324  
325 if (@item > 1) {
326 unshift @data, @item; @item = shift @data;
327 }
328  
329 @item = (_find_in_perl($seen, $conf, @item));
330  
331 if (@item > 1) {
332 unshift @data, @item; @item = shift @data;
333 }
334  
335 @item = (_find_in_task($seen, $conf, @item));
336  
337 if (@item > 1) {
338 unshift @data, @item; @item = shift @data;
339 }
340  
341 @item = (_find_in_vars($seen, $conf, @item));
342  
343 if (@item > 1) {
344 unshift @data, @item; @item = shift @data;
345 }
346  
347 @item = (_find_in_with($seen, $conf, @item));
348  
349 if (@item > 1) {
350 shift @data; unshift @data, @item; @item = shift @data;
351 }
352  
353 return (@item, @data);
354 }
355  
356 sub _find_in_exec {
357 my ($seen, $conf, $item) = @_;
358  
359 return $conf->{exec}
360 ? (
361 $conf->{exec}{$item}
362 ? (do {
363 my $value = $conf->{exec}{$item};
364 ($value eq $item)
365 ? ($value)
366 : (_find_in_seen($seen, $conf, 'exec', $item, $value));
367 })
368 : ($item)
369 )
370 : ($item);
371 }
372  
373 sub _find_in_find {
374 my ($seen, $conf, $item) = @_;
375  
376 return $conf->{find}
377 ? (
378 $conf->{find}{$item}
379 ? (do {
380 my $value = $conf->{find}{$item};
381 ($value eq $item)
382 ? ($value)
383 : (_find_in_seen($seen, $conf, 'find', $item, $value));
384 })
385 : ($item)
386 )
387 : ($item);
388 }
389  
390 sub _find_in_flow {
391 my ($seen, $conf, $item) = @_;
392  
393 return $conf->{flow}
394 ? (
395 $conf->{flow}{$item}
396 ? (do {
397 my $value = $conf->{flow}{$item};
398 join ' && ', map +(join(' ', _exec(sub{}, $conf, $_))), @{$value}
399 })
400 : ($item)
401 )
402 : ($item);
403 }
404  
405 sub _find_in_func {
406 my ($seen, $conf, $item) = @_;
407  
408 return $conf->{func}
409 ? (
410 $conf->{func}{$item}
411 ? (do {
412 my $value = _vars($conf->{func}{$item});
413 ('perl', '-E', "(do \"$value\")->(\\\@ARGV)")
414 })
415 : ($item)
416 )
417 : ($item);
418 }
419  
420 sub _find_in_perl {
421 my ($seen, $conf, $item) = @_;
422  
423 return $conf->{perl}
424 ? (
425 $conf->{perl}{$item}
426 ? (do {
427 my $value = $conf->{perl}{$item};
428 ($value eq $item)
429 ? ($value)
430 : (_find_in_seen($seen, $conf, 'perl', $item, $value));
431 },
432 _load_from_libs($seen, $conf),
433 _load_from_load($seen, $conf),
434 )
435 : ($item)
436 )
437 : ($item);
438 }
439  
440 sub _find_in_task {
441 my ($seen, $conf, $item) = @_;
442  
443 return $conf->{task}
444 ? (
445 $conf->{task}{$item}
446 ? (do {
447 $ENV{VENUS_TASK_AUTO} = 1;
448 my $value = $conf->{task}{$item};
449 ($value eq $item)
450 ? ($value)
451 : (_find_in_seen($seen, $conf, 'task', $item, $value));
452 })
453 : ($item)
454 )
455 : ($item);
456 }
457  
458 sub _find_in_vars {
459 my ($seen, $conf, $item) = @_;
460  
461 my ($name) = $item =~ /\$?(.*)/;
462  
463 return $conf->{vars}
464 ? (
465 $conf->{vars}{$name}
466 ? (do {
467 my $value = $conf->{vars}{$name};
468 ($value eq $name)
469 ? ($value)
470 : (_find_in_seen($seen, $conf, 'vars', $name, $value));
471 })
472 : ($item)
473 )
474 : ($item);
475 }
476  
477 sub _find_in_with {
478 my ($seen, $conf, $item) = @_;
479  
480 return $conf->{with}
481 ? (
482 $conf->{with}{$item}
483 ? (do {
484 $ENV{ECHO} = 0;
485 $ENV{VENUS_FILE} = _vars($conf->{with}{$item});
486 $ENV{VENUS_TASK_NAME} || 'vns';
487 })
488 : ($item)
489 )
490 : ($item);
491 }
492  
493 sub _find_in_seen {
494 my ($seen, $conf, $item, $name, $value) = @_;
495  
496 return $seen->{$item}{$name}++
497 ? ((_split($value))[0])
498 : (_find($seen, $conf, $value));
499 }
500  
501 sub _flow {
502 my ($conf, @data) = @_;
503  
504 return () if !@data;
505  
506 my $item = shift @data;
507  
508 return $conf->{flow}
509 ? (
510 $conf->{flow}{$item}
511 ? (do {
512 (map _flow($conf, $_, @data), @{$conf->{flow}{$item}});
513 })
514 : (_prep($conf, $item, @data))
515 )
516 : (_prep($conf, $item, @data));
517 }
518  
519 sub _libs {
520 my ($conf) = @_;
521  
522 return (map /^-I\w*?(.*)$/, _load_from_libs({}, $conf));
523 }
524  
525 sub _load_from_libs {
526 my ($seen, $conf) = @_;
527  
528 return !$seen->{libs}++ ? ($conf->{libs} ? (@{$conf->{libs}}) : ()) : ();
529 }
530  
531 sub _load_from_load {
532 my ($seen, $conf) = @_;
533  
534 return !$seen->{load}++ ? ($conf->{load} ? (@{$conf->{load}}) : ()) : ();
535 }
536  
537 sub _make {
538 my ($conf, $name) = @_;
539  
540 my ($item, @data) = _find({}, $conf, $name);
541  
542 require Venus::Os;
543  
544 my $path = Venus::Os->which($item);
545  
546 return (($path ? $path : $item), @data);
547 }
548  
549 sub _prep {
550 my ($conf, @data) = @_;
551  
552 my @args = grep defined, _make($conf, shift(@data)), @data;
553  
554 my $prog = _vars(shift(@args));
555  
556 require Venus::Os;
557  
558 for (my $i = 0; $i < @args; $i++) {
559 if ($args[$i] =~ /^\|+$/) {
560 next;
561 }
562 if ($args[$i] =~ /^\&+$/) {
563 next;
564 }
565 if ($args[$i] =~ /^\w+$/) {
566 next;
567 }
568 if ($args[$i] =~ /^[<>]+$/) {
569 next;
570 }
571 if ($args[$i] =~ /^\d[<>&]+\d?$/) {
572 next;
573 }
574 if ($args[$i] =~ /^\$[A-Z]\w+$/) {
575 $args[$i] = _vars($args[$i]);
576 next;
577 }
578 if ($args[$i] =~ /^\$\((.*)\)$/) {
579 if ($1) {
580 $args[$i] = "\$(@{[@{_prep($conf, $1)}]})";
581 }
582 next;
583 }
584 $args[$i] = Venus::Os->quote($args[$i]);
585 }
586  
587 return [$prog ? ($prog, @args) : ()];
588 }
589  
590 sub _split {
591 my ($text) = @_;
592  
593 return (grep length, ($text // '') =~ /(?x)(?:"([^"]*)"|([^\s]*))\s?/g);
594 }
595  
596 sub _set_conf {
597 my ($conf) = @_;
598  
599 $conf = Venus::merge(Venus::Config->read_file(_vars($_))->value, $conf)
600 for (
601 $conf->{from}
602 ? ((ref $conf->{from} eq 'ARRAY') ? (@{$conf->{from}}) : ($conf->{from}))
603 : ()
604 );
605  
606 if (exists $conf->{when}) {
607 require Venus::Os;
608  
609 my $type = Venus::Os->type;
610  
611 if (exists $conf->{when}{$type}) {
612 $conf = Venus::merge($conf, $conf->{when}{$type});
613 }
614 }
615  
616 return $conf;
617 }
618  
619 sub _set_libs {
620 my ($conf) = @_;
621  
622 require Venus::Os;
623 require Venus::Path;
624  
625 my %seen;
626 $ENV{PERL5LIB} = join((Venus::Os->is_win ? ';' : ':'),
627 (grep !$seen{$_}++, map Venus::Path->new(_vars($_))->absolute, _libs($conf)));
628  
629 return $conf;
630 }
631  
632 sub _set_path {
633 my ($conf) = @_;
634  
635 require Venus::Os;
636 require Venus::Path;
637  
638 if (my $path = $conf->{path}) {
639 $ENV{PATH} = join((Venus::Os->is_win ? ';' : ':'),
640 (map Venus::Path->new(_vars($_))->absolute, @{$conf->{path}}), $ENV{PATH});
641 }
642  
643 return $conf;
644 }
645  
646 sub _set_vars {
647 my ($conf) = @_;
648  
649 if (my $data = $conf->{data}) {
650 for my $key (sort keys %{$data}) {
651 $ENV{$key} = join(' ', grep defined, $data->{$key});
652 }
653 }
654  
655 if (my $vars = $conf->{vars}) {
656 for my $key (sort keys %{$vars}) {
657 $ENV{$key} = join(' ', grep defined, @{_prep($conf, $vars->{$key})});
658 }
659 }
660  
661 if (my $asks = $conf->{asks}) {
662 for my $key (sort keys %{$asks}) {
663 next if defined $ENV{$key}; _print $asks->{$key}; $ENV{$key} = _prompt;
664 }
665 }
666  
667 return $conf;
668 }
669  
670 sub _vars {
671 (($_[0] // '') =~ s{\$([A-Z_]+)}{$ENV{$1}//"\$".$1}egr)
672 }
673  
674 # AUTORUN
675  
676 run Venus::Run;
677  
678 1;
679  
680  
681  
682 =head1 NAME
683  
684 Venus::Run - Runner Class
685  
686 =cut
687  
688 =head1 ABSTRACT
689  
690 Runner Class for Perl 5
691  
692 =cut
693  
694 =head1 SYNOPSIS
695  
696 package main;
697  
698 use Venus::Run;
699  
700 my $run = Venus::Run->new;
701  
702 # bless({...}, 'Venus::Run')
703  
704 =cut
705  
706 =head1 DESCRIPTION
707  
708 This package is a subclass of L<Venus::Task> which provides a command execution
709 system. This package loads the configuration file used for defining tasks (i.e.
710 command-line operations) which can recursively resolve, injects environment
711 variables, resets the C<PATH> and C<PERL5LIB> variables where appropriate, and
712 executes the tasks by name. See L<vns> for an executable file which loads this
713 package and provides the CLI. See L</FEATURES> for usage and configuration
714 information.
715  
716 =cut
717  
718 =head1 INHERITS
719  
720 This package inherits behaviors from:
721  
722 L<Venus::Task>
723  
724 =cut
725  
726 =head1 METHODS
727  
728 This package provides the following methods:
729  
730 =cut
731  
732 =head2 args
733  
734 args() (hashref)
735  
736 The args method returns the task argument declarations.
737  
738 I<Since C<2.91>>
739  
740 =over 4
741  
742 =item args example 1
743  
744 # given: synopsis
745  
746 package main;
747  
748 my $args = $run->args;
749  
750 # {
751 # 'command' => {
752 # help => 'Command to run',
753 # required => 1,
754 # }
755 # }
756  
757 =back
758  
759 =cut
760  
761 =head2 cmds
762  
763 cmds() (hashref)
764  
765 The cmds method returns the task command declarations.
766  
767 I<Since C<2.91>>
768  
769 =over 4
770  
771 =item cmds example 1
772  
773 # given: synopsis
774  
775 package main;
776  
777 my $cmds = $run->cmds;
778  
779 # {
780 # 'help' => {
781 # help => 'Display help and usages',
782 # arg => 'command',
783 # },
784 # 'init' => {
785 # help => 'Initialize the configuration file',
786 # arg => 'command',
787 # },
788 # }
789  
790 =back
791  
792 =cut
793  
794 =head2 conf
795  
796 conf() (hashref)
797  
798 The conf method loads the configuration file returned by L</file>, then decodes
799 and returns the information as a hashref.
800  
801 I<Since C<2.91>>
802  
803 =over 4
804  
805 =item conf example 1
806  
807 # given: synopsis
808  
809 package main;
810  
811 my $conf = $run->conf;
812  
813 # {}
814  
815 =back
816  
817 =over 4
818  
819 =item conf example 2
820  
821 # given: synopsis
822  
823 package main;
824  
825 local $ENV{VENUS_FILE} = 't/conf/.vns.pl';
826  
827 my $conf = $run->conf;
828  
829 # {...}
830  
831 =back
832  
833 =over 4
834  
835 =item conf example 3
836  
837 # given: synopsis
838  
839 package main;
840  
841 # e.g. current directory has only a .vns.yaml file
842  
843 my $conf = $run->conf;
844  
845 # {...}
846  
847 =back
848  
849 =over 4
850  
851 =item conf example 4
852  
853 # given: synopsis
854  
855 package main;
856  
857 # e.g. current directory has only a .vns.yml file
858  
859 my $conf = $run->conf;
860  
861 # {...}
862  
863 =back
864  
865 =over 4
866  
867 =item conf example 5
868  
869 # given: synopsis
870  
871 package main;
872  
873 # e.g. current directory has only a .vns.json file
874  
875 my $conf = $run->conf;
876  
877 # {...}
878  
879 =back
880  
881 =over 4
882  
883 =item conf example 6
884  
885 # given: synopsis
886  
887 package main;
888  
889 # e.g. current directory has only a .vns.js file
890  
891 my $conf = $run->conf;
892  
893 # {...}
894  
895 =back
896  
897 =over 4
898  
899 =item conf example 7
900  
901 # given: synopsis
902  
903 package main;
904  
905 # e.g. current directory has only a .vns.perl file
906  
907 my $conf = $run->conf;
908  
909 # {...}
910  
911 =back
912  
913 =over 4
914  
915 =item conf example 8
916  
917 # given: synopsis
918  
919 package main;
920  
921 # e.g. current directory has only a .vns.pl file
922  
923 my $conf = $run->conf;
924  
925 # {...}
926  
927 =back
928  
929 =cut
930  
931 =head2 file
932  
933 file() (string)
934  
935 The file method returns the configuration file specified in the C<VENUS_FILE>
936 environment variable, or the discovered configuration file in the current
937 directory. The default name for a configuration file is in the form of
938 C<.vns.*>. Configuration files will be decoded based on their file extensions.
939 Valid file extensions are C<yaml>, C<yml>, C<json>, C<js>, C<perl>, and C<pl>.
940  
941 I<Since C<2.91>>
942  
943 =over 4
944  
945 =item file example 1
946  
947 # given: synopsis
948  
949 package main;
950  
951 my $file = $run->file;
952  
953 # undef
954  
955 =back
956  
957 =over 4
958  
959 =item file example 2
960  
961 # given: synopsis
962  
963 package main;
964  
965 local $ENV{VENUS_FILE} = 't/conf/.vns.pl';
966  
967 my $file = $run->file;
968  
969 # "t/conf/.vns.pl"
970  
971 =back
972  
973 =over 4
974  
975 =item file example 3
976  
977 # given: synopsis
978  
979 package main;
980  
981 # e.g. current directory has only a .vns.yaml file
982  
983 my $file = $run->file;
984  
985 # ".vns.yaml"
986  
987 =back
988  
989 =over 4
990  
991 =item file example 4
992  
993 # given: synopsis
994  
995 package main;
996  
997 # e.g. current directory has only a .vns.yml file
998  
999 my $file = $run->file;
1000  
1001 # ".vns.yml"
1002  
1003 =back
1004  
1005 =over 4
1006  
1007 =item file example 5
1008  
1009 # given: synopsis
1010  
1011 package main;
1012  
1013 # e.g. current directory has only a .vns.json file
1014  
1015 my $file = $run->file;
1016  
1017 # ".vns.json"
1018  
1019 =back
1020  
1021 =over 4
1022  
1023 =item file example 6
1024  
1025 # given: synopsis
1026  
1027 package main;
1028  
1029 # e.g. current directory has only a .vns.js file
1030  
1031 my $file = $run->file;
1032  
1033 # ".vns.js"
1034  
1035 =back
1036  
1037 =over 4
1038  
1039 =item file example 7
1040  
1041 # given: synopsis
1042  
1043 package main;
1044  
1045 # e.g. current directory has only a .vns.perl file
1046  
1047 my $file = $run->file;
1048  
1049 # ".vns.perl"
1050  
1051 =back
1052  
1053 =over 4
1054  
1055 =item file example 8
1056  
1057 # given: synopsis
1058  
1059 package main;
1060  
1061 # e.g. current directory has only a .vns.pl file
1062  
1063 my $file = $run->file;
1064  
1065 # ".vns.pl"
1066  
1067 =back
1068  
1069 =cut
1070  
1071 =head2 footer
1072  
1073 footer() (string)
1074  
1075 The footer method returns examples and usage information used in usage text.
1076  
1077 I<Since C<2.91>>
1078  
1079 =over 4
1080  
1081 =item footer example 1
1082  
1083 # given: synopsis
1084  
1085 package main;
1086  
1087 my $footer = $run->footer;
1088  
1089 # "..."
1090  
1091 =back
1092  
1093 =cut
1094  
1095 =head2 handler
1096  
1097 handler(hashref $data) (any)
1098  
1099 The handler method processes the data provided and executes the request then
1100 returns the invocant unless the program is exited.
1101  
1102 I<Since C<2.91>>
1103  
1104 =over 4
1105  
1106 =item handler example 1
1107  
1108 package main;
1109  
1110 use Venus::Run;
1111  
1112 my $run = Venus::Run->new;
1113  
1114 $run->execute;
1115  
1116 # ()
1117  
1118 =back
1119  
1120 =over 4
1121  
1122 =item handler example 2
1123  
1124 package main;
1125  
1126 use Venus::Run;
1127  
1128 my $run = Venus::Run->new(['help']);
1129  
1130 $run->execute;
1131  
1132 # ()
1133  
1134 =back
1135  
1136 =over 4
1137  
1138 =item handler example 3
1139  
1140 package main;
1141  
1142 use Venus::Run;
1143  
1144 my $run = Venus::Run->new(['--help']);
1145  
1146 $run->execute;
1147  
1148 # ()
1149  
1150 =back
1151  
1152 =over 4
1153  
1154 =item handler example 4
1155  
1156 package main;
1157  
1158 use Venus::Run;
1159  
1160 my $run = Venus::Run->new(['init']);
1161  
1162 $run->execute;
1163  
1164 # ()
1165  
1166 =back
1167  
1168 =over 4
1169  
1170 =item handler example 5
1171  
1172 package main;
1173  
1174 use Venus::Run;
1175  
1176 # on linux
1177  
1178 my $run = Venus::Run->new(['echo']);
1179  
1180 $run->execute;
1181  
1182 # ()
1183  
1184 # i.e. ['echo']
1185  
1186 =back
1187  
1188 =over 4
1189  
1190 =item handler example 6
1191  
1192 package main;
1193  
1194 use Venus::Run;
1195  
1196 # on linux
1197  
1198 # in config
1199 #
1200 # ---
1201 # exec:
1202 # cpan: cpanm -llocal -qn
1203 #
1204 # ...
1205  
1206 my $run = Venus::Run->new(['cpan', 'Venus']);
1207  
1208 $run->execute;
1209  
1210 # ()
1211  
1212 # i.e. cpanm '-llocal' '-qn' Venus
1213  
1214 =back
1215  
1216 =over 4
1217  
1218 =item handler example 7
1219  
1220 package main;
1221  
1222 use Venus::Run;
1223  
1224 # on linux
1225  
1226 # in config
1227 #
1228 # ---
1229 # exec:
1230 # cpan: cpanm -llocal -qn
1231 # deps: cpan --installdeps .
1232 #
1233 # ...
1234  
1235 my $run = Venus::Run->new(['cpan', '--installdeps', '.']);
1236  
1237 $run->execute;
1238  
1239 # ()
1240  
1241 # i.e. cpanm '-llocal' '-qn' '--installdeps' '.'
1242  
1243 =back
1244  
1245 =over 4
1246  
1247 =item handler example 8
1248  
1249 package main;
1250  
1251 use Venus::Run;
1252  
1253 # on linux
1254  
1255 # in config
1256 #
1257 # ---
1258 # exec:
1259 # okay: $PERL -c
1260 #
1261 # ...
1262 #
1263 # libs:
1264 # - -Ilib
1265 # - -Ilocal/lib/perl5
1266 #
1267 # ...
1268 #
1269 # vars:
1270 # PERL: perl
1271 #
1272 # ...
1273  
1274 my $run = Venus::Run->new(['okay', 'lib/Venus.pm']);
1275  
1276 $run->execute;
1277  
1278 # ()
1279  
1280 # i.e. perl '-Ilib' '-Ilocal/lib/perl5' '-c'
1281  
1282 =back
1283  
1284 =over 4
1285  
1286 =item handler example 9
1287  
1288 package main;
1289  
1290 use Venus::Run;
1291  
1292 # on linux
1293  
1294 # in config
1295 #
1296 # ---
1297 # exec:
1298 # repl: $REPL
1299 #
1300 # ...
1301 #
1302 # libs:
1303 # - -Ilib
1304 # - -Ilocal/lib/perl5
1305 #
1306 # ...
1307 #
1308 # vars:
1309 # PERL: perl
1310 # REPL: $PERL -dE0
1311 #
1312 # ...
1313  
1314 my $run = Venus::Run->new(['repl']);
1315  
1316 $run->execute;
1317  
1318 # ()
1319  
1320 # i.e. perl '-Ilib' '-Ilocal/lib/perl5' '-dE0'
1321  
1322 =back
1323  
1324 =over 4
1325  
1326 =item handler example 10
1327  
1328 package main;
1329  
1330 use Venus::Run;
1331  
1332 # on linux
1333  
1334 # in config
1335 #
1336 # ---
1337 # exec:
1338 # exec: $PERL
1339 #
1340 # ...
1341 #
1342 # libs:
1343 # - -Ilib
1344 # - -Ilocal/lib/perl5
1345 #
1346 # ...
1347 #
1348 # vars:
1349 # PERL: perl
1350 #
1351 # ...
1352  
1353 my $run = Venus::Run->new(['exec', '-MVenus=date', 'say date']);
1354  
1355 $run->execute;
1356  
1357 # ()
1358  
1359 # i.e. perl '-Ilib' '-Ilocal/lib/perl5' '-MVenus=date' 'say date'
1360  
1361 =back
1362  
1363 =over 4
1364  
1365 =item handler example 11
1366  
1367 package main;
1368  
1369 use Venus::Run;
1370  
1371 # on linux
1372  
1373 # in config
1374 #
1375 # ---
1376 # exec:
1377 # test: $PROVE
1378 #
1379 # ...
1380 #
1381 # libs:
1382 # - -Ilib
1383 # - -Ilocal/lib/perl5
1384 #
1385 # ...
1386 #
1387 # vars:
1388 # PROVE: prove
1389 #
1390 # ...
1391  
1392 my $run = Venus::Run->new(['test', 't']);
1393  
1394 $run->execute;
1395  
1396 # ()
1397  
1398 # i.e. prove '-Ilib' '-Ilocal/lib/perl5' t
1399  
1400 =back
1401  
1402 =over 4
1403  
1404 =item handler example 12
1405  
1406 package main;
1407  
1408 use Venus::Run;
1409  
1410 # on linux
1411  
1412 my $run = Venus::Run->new(['echo', 1, '|', 'less']);
1413  
1414 $run->execute;
1415  
1416 # ()
1417  
1418 # i.e. echo 1 | less
1419  
1420 =back
1421  
1422 =over 4
1423  
1424 =item handler example 13
1425  
1426 package main;
1427  
1428 use Venus::Run;
1429  
1430 # on linux
1431  
1432 my $run = Venus::Run->new(['echo', 1, '&&', 'echo', 2]);
1433  
1434 $run->execute;
1435  
1436 # ()
1437  
1438 # i.e. echo 1 && echo 2
1439  
1440 =back
1441  
1442 =over 4
1443  
1444 =item handler example 14
1445  
1446 package main;
1447  
1448 use Venus::Run;
1449  
1450 # on linux
1451  
1452 local $ENV{VENUS_FILE} = 't/conf/from.perl';
1453  
1454 # in config
1455 #
1456 # ---
1457 # from:
1458 # - /path/to/parent
1459 #
1460 # ...
1461 #
1462 # exec:
1463 # mypan: cpan -M https://pkg.myapp.com
1464  
1465 # in config (/path/to/parent)
1466 #
1467 # ---
1468 # exec:
1469 # cpan: cpanm -llocal -qn
1470 #
1471 # ...
1472  
1473 my $run = Venus::Run->new(['mypan']);
1474  
1475 $run->execute;
1476  
1477 # ()
1478  
1479 # i.e. cpanm '-llocal' '-qn' '-M' 'https://pkg.myapp.com'
1480  
1481 =back
1482  
1483 =over 4
1484  
1485 =item handler example 15
1486  
1487 package main;
1488  
1489 use Venus::Run;
1490  
1491 # on linux
1492  
1493 local $ENV{VENUS_FILE} = 't/conf/with.perl';
1494  
1495 # in config
1496 #
1497 # ---
1498 # with:
1499 # psql: /path/to/other
1500 #
1501 # ...
1502  
1503 # in config (/path/to/other)
1504 #
1505 # ---
1506 # exec:
1507 # backup: pg_backupcluster
1508 # restore: pg_restorecluster
1509 #
1510 # ...
1511  
1512 my $run = Venus::Run->new(['psql', 'backup']);
1513  
1514 $run->execute;
1515  
1516 # ()
1517  
1518 # i.e. vns backup
1519  
1520 =back
1521  
1522 =over 4
1523  
1524 =item handler example 16
1525  
1526 package main;
1527  
1528 use Venus::Run;
1529  
1530 # on linux
1531  
1532 local $ENV{VENUS_FILE} = 't/conf/with.perl';
1533  
1534 # in config
1535 #
1536 # ---
1537 # with:
1538 # psql: /path/to/other
1539 #
1540 # ...
1541  
1542 # in config (/path/to/other)
1543 #
1544 # ---
1545 # exec:
1546 # backup: pg_backupcluster
1547 # restore: pg_restorecluster
1548 #
1549 # ...
1550  
1551 my $run = Venus::Run->new(['psql', 'backup']);
1552  
1553 $run->execute;
1554  
1555 # VENUS_FILE=t/conf/psql.perl vns backup
1556  
1557 local $ENV{VENUS_FILE} = 't/conf/psql.perl';
1558  
1559 $run = Venus::Run->new(['backup']);
1560  
1561 $run->execute;
1562  
1563 # ()
1564  
1565 # i.e. pg_backupcluster
1566  
1567 =back
1568  
1569 =over 4
1570  
1571 =item handler example 17
1572  
1573 package main;
1574  
1575 use Venus::Run;
1576  
1577 # on linux
1578  
1579 # in config
1580 #
1581 # ---
1582 # exec:
1583 # cpan: cpanm -llocal -qn
1584 #
1585 # ...
1586 #
1587 # flow:
1588 # setup-term:
1589 # - cpan Term::ReadKey
1590 # - cpan Term::ReadLine::Gnu
1591 #
1592 # ...
1593  
1594 local $ENV{VENUS_FILE} = 't/conf/flow.perl';
1595  
1596 my $run = Venus::Run->new(['setup-term']);
1597  
1598 $run->execute;
1599  
1600 # ()
1601  
1602 # i.e.
1603 # cpanm '-llocal' '-qn' 'Term::ReadKey'
1604 # cpanm '-llocal' '-qn' 'Term::ReadLine::Gnu'
1605  
1606 =back
1607  
1608 =over 4
1609  
1610 =item handler example 18
1611  
1612 package main;
1613  
1614 use Venus::Run;
1615  
1616 # on linux
1617  
1618 # in config
1619 #
1620 # ---
1621 # asks:
1622 # PASS: What's the password
1623 #
1624 # ...
1625  
1626 local $ENV{VENUS_FILE} = 't/conf/asks.perl';
1627  
1628 my $run = Venus::Run->new(['echo', '$PASS']);
1629  
1630 $run->execute;
1631  
1632 # ()
1633  
1634 # i.e. echo '$PASS'
1635  
1636 =back
1637  
1638 =over 4
1639  
1640 =item handler example 19
1641  
1642 package main;
1643  
1644 use Venus::Run;
1645  
1646 # on linux
1647  
1648 # in config
1649 #
1650 # ---
1651 # func:
1652 # dump: /path/to/dump.pl
1653 #
1654 # ...
1655  
1656 # in dump.pl (/path/to/dump.pl)
1657 #
1658 # sub {
1659 # my ($args) = @_;
1660 #
1661 # ...
1662 # }
1663  
1664 local $ENV{VENUS_FILE} = 't/conf/func.perl';
1665  
1666 my $run = Venus::Run->new(['dump', '--', 'hello']);
1667  
1668 $run->execute;
1669  
1670 # ()
1671  
1672 # i.e. perl -Ilib ... -E '(do "./t/path/etc/dump.pl")->(\@ARGV)' '--' hello
1673  
1674 =back
1675  
1676 =over 4
1677  
1678 =item handler example 20
1679  
1680 package main;
1681  
1682 use Venus::Run;
1683  
1684 # on linux
1685  
1686 local $ENV{VENUS_FILE} = 't/conf/when.perl';
1687  
1688 # in config
1689 #
1690 # ---
1691 # exec:
1692 # name: echo $OSNAME
1693 #
1694 # ...
1695 # when:
1696 # is_lin:
1697 # data:
1698 # OSNAME: LINUX
1699 # is_win:
1700 # data:
1701 # OSNAME: WINDOW
1702 #
1703 # ...
1704  
1705 my $run = Venus::Run->new(['name']);
1706  
1707 $run->execute;
1708  
1709 # ()
1710  
1711 # i.e. echo $OSNAME
1712  
1713 # i.e. echo LINUX
1714  
1715 =back
1716  
1717 =over 4
1718  
1719 =item handler example 21
1720  
1721 package main;
1722  
1723 use Venus::Run;
1724  
1725 # on mswin32
1726  
1727 local $ENV{VENUS_FILE} = 't/conf/when.perl';
1728  
1729 # in config
1730 #
1731 # ---
1732 # exec:
1733 # name: echo $OSNAME
1734 #
1735 # ...
1736 # when:
1737 # is_lin:
1738 # data:
1739 # OSNAME: LINUX
1740 # is_win:
1741 # data:
1742 # OSNAME: WINDOW
1743 #
1744 # ...
1745  
1746 my $run = Venus::Run->new(['name']);
1747  
1748 $run->execute;
1749  
1750 # ()
1751  
1752 # i.e. echo $OSNAME
1753  
1754 # i.e. echo WINDOWS
1755  
1756 =back
1757  
1758 =over 4
1759  
1760 =item handler example 22
1761  
1762 package main;
1763  
1764 use Venus::Run;
1765  
1766 # on linux
1767  
1768 local $ENV{VENUS_FILE} = 't/conf/help.perl';
1769  
1770 # in config
1771 #
1772 # ---
1773 # exec:
1774 # exec: perl -c
1775 #
1776 # ...
1777 # help:
1778 # exec: Usage: perl -c <FILE>
1779 #
1780 # ...
1781  
1782 my $run = Venus::Run->new(['help', 'exec']);
1783  
1784 $run->execute;
1785  
1786 # ()
1787  
1788 # i.e. Usage: perl -c <FILE>
1789  
1790 =back
1791  
1792 =cut
1793  
1794 =head2 init
1795  
1796 init() (hashref)
1797  
1798 The init method returns the default configuration to be used when initializing
1799 the system with a new configuration file.
1800  
1801 I<Since C<2.91>>
1802  
1803 =over 4
1804  
1805 =item init example 1
1806  
1807 # given: synopsis
1808  
1809 package main;
1810  
1811 my $init = $run->init;
1812  
1813 # {
1814 # data => {
1815 # ECHO => 1,
1816 # },
1817 # exec => {
1818 # brew => 'perlbrew',
1819 # cpan => 'cpanm -llocal -qn',
1820 # docs => 'perldoc',
1821 # each => 'shim -nE',
1822 # edit => '$EDITOR $VENUS_FILE',
1823 # eval => 'shim -E',
1824 # exec => '$PERL',
1825 # info => '$PERL -V',
1826 # lint => 'perlcritic',
1827 # okay => '$PERL -c',
1828 # repl => '$REPL',
1829 # reup => 'cpanm -qn Venus',
1830 # says => 'eval "map log(eval), @ARGV"',
1831 # shim => '$PERL -MVenus=true,false,log',
1832 # test => '$PROVE',
1833 # tidy => 'perltidy',
1834 # },
1835 # libs => [
1836 # '-Ilib',
1837 # '-Ilocal/lib/perl5',
1838 # ],
1839 # path => [
1840 # './bin',
1841 # './dev',
1842 # './local/bin',
1843 # ],
1844 # perl => {
1845 # perl => 'perl',
1846 # prove => 'prove',
1847 # },
1848 # vars => {
1849 # PERL => 'perl',
1850 # PROVE => 'prove'
1851 # REPL => '$PERL -dE0'
1852 # },
1853 # }
1854  
1855 =back
1856  
1857 =cut
1858  
1859 =head2 name
1860  
1861 name() (string)
1862  
1863 The name method returns the default name for the task. This is used in usage
1864 text and can be controlled via the C<VENUS_TASK_NAME> environment variable, or
1865 the C<NAME> package variable.
1866  
1867 I<Since C<2.91>>
1868  
1869 =over 4
1870  
1871 =item name example 1
1872  
1873 # given: synopsis
1874  
1875 package main;
1876  
1877 my $name = $run->name;
1878  
1879 # "Venus::Run"
1880  
1881 =back
1882  
1883 =over 4
1884  
1885 =item name example 2
1886  
1887 # given: synopsis
1888  
1889 package main;
1890  
1891 local $ENV{VENUS_TASK_NAME} = 'venus-runner';
1892  
1893 my $name = $run->name;
1894  
1895 # "venus-runner"
1896  
1897 =back
1898  
1899 =over 4
1900  
1901 =item name example 3
1902  
1903 # given: synopsis
1904  
1905 package main;
1906  
1907 local $Venus::Run::NAME = 'venus-runner';
1908  
1909 my $name = $run->name;
1910  
1911 # "venus-runner"
1912  
1913 =back
1914  
1915 =cut
1916  
1917 =head2 opts
1918  
1919 opts() (hashref)
1920  
1921 The opts method returns the task options declarations.
1922  
1923 I<Since C<2.91>>
1924  
1925 =over 4
1926  
1927 =item opts example 1
1928  
1929 # given: synopsis
1930  
1931 package main;
1932  
1933 my $opts = $run->opts;
1934  
1935 # {
1936 # 'help' => {
1937 # help => 'Show help information',
1938 # }
1939 # }
1940  
1941 =back
1942  
1943 =cut
1944  
1945 =head1 FEATURES
1946  
1947 This package provides the following features:
1948  
1949 =cut
1950  
1951 =over 4
1952  
1953 =item config
1954  
1955 The CLI provided by this package operates on a configuration file, typically
1956 having a base name of C<.vns> with a Perl, JSON, or YAML file extension. Here
1957 is an example of a configuration file using YAML with the filename
1958 C<.vns.yaml>.
1959  
1960 ---
1961 data:
1962 ECHO: true
1963 exec:
1964 cpan: cpanm -llocal -qn
1965 okay: $PERL -c
1966 repl: $PERL -dE0
1967 says: $PERL -E "map log(eval), @ARGV"
1968 test: $PROVE
1969 libs:
1970 - -Ilib
1971 - -Ilocal/lib/perl5
1972 load:
1973 - -MVenus=true,false
1974 path:
1975 - ./bin
1976 - ./dev
1977 - -Ilocal/bin
1978 perl:
1979 perl: perl
1980 prove: prove
1981 vars:
1982 PERL: perl
1983 PROVE: prove
1984  
1985 =back
1986  
1987 =over 4
1988  
1989 =item config-asks
1990  
1991 ---
1992 asks:
1993 HOME: Enter your home dir
1994  
1995 The configuration file's C<asks> section provides a list of key/value pairs
1996 where the key is the name of the environment variable and the value is used as
1997 the message used by the CLI to prompt for input if the environment variable is
1998 not defined.
1999  
2000 =back
2001  
2002 =over 4
2003  
2004 =item config-data
2005  
2006 ---
2007 data:
2008 ECHO: true
2009  
2010 The configuration file's C<data> section provides a non-dynamic list of
2011 key/value pairs that will be used as environment variables.
2012  
2013 =back
2014  
2015 =over 4
2016  
2017 =item config-exec
2018  
2019 ---
2020 exec:
2021 okay: $PERL -c
2022  
2023 The configuration file's C<exec> section provides the main dynamic tasks which
2024 can be recursively resolved and expanded.
2025  
2026 =back
2027  
2028 =over 4
2029  
2030 =item config-find
2031  
2032 ---
2033 find:
2034 cpanm: /usr/local/bin/cpanm
2035  
2036 The configuration file's C<find> section provides aliases which can be
2037 recursively resolved and expanded for use in other tasks.
2038  
2039 =back
2040  
2041 =over 4
2042  
2043 =item config-flow
2044  
2045 ---
2046 flow:
2047 deps:
2048 - cpan Term::ReadKey
2049 - cpan Term::ReadLine::Gnu
2050  
2051 The configuration file's C<flow> section provides chainable tasks which are
2052 recursively resolved and expanded from other tasks.
2053  
2054 =back
2055  
2056 =over 4
2057  
2058 =item config-from
2059  
2060 ---
2061 from:
2062 - /usr/share/vns/.vns.yaml
2063  
2064 The configuration file's C<from> section provides paths to other configuration
2065 files which will be merged before execution allowing the inheritance of of
2066 configuration values.
2067  
2068 =back
2069  
2070 =over 4
2071  
2072 =item config-func
2073  
2074 ---
2075 func:
2076 build: ./scripts/build.pl
2077  
2078 The configuration file's C<func> section provides a list of static key/value
2079 pairs where the key is the "subcommand" passed to the runner as the first
2080 arugment, and the value is the Perl script that will be loaded and executed.
2081 The Perl script is expected to return a subroutine reference and will be passed
2082 an array reference to the arguments provided.
2083  
2084 =back
2085  
2086 =over 4
2087  
2088 =item config-help
2089  
2090 ---
2091 help:
2092 build: Usage: vns build [<option>]
2093  
2094 The configuration file's C<help> section provides a list of static key/value
2095 pairs where the key is the "subcommand" to display help text for, and the value
2096 is the help text to be displayed.
2097  
2098 =back
2099  
2100 =over 4
2101  
2102 =item config-libs
2103  
2104 ---
2105 libs:
2106 - -Ilib
2107 - -Ilocal/lib/perl5
2108  
2109 The configuration file's C<libs> section provides a list of C<-I/path/to/lib>
2110 "include" statements that will be automatically added to tasks expanded from
2111 the C<perl> section.
2112  
2113 =back
2114  
2115 =over 4
2116  
2117 =item config-load
2118  
2119 ---
2120 load:
2121 - -MVenus=true,false
2122  
2123 The configuration file's C<load> section provides a list of C<-MPackage>
2124 "import" statements that will be automatically added to tasks expanded from the
2125 C<perl> section.
2126  
2127 =back
2128  
2129 =over 4
2130  
2131 =item config-path
2132  
2133 ---
2134 path:
2135 - ./bin
2136 - ./dev
2137 - -Ilocal/bin
2138  
2139 The configuration file's C<path> section provides a list of paths to be
2140 prepended to the C<PATH> environment variable which allows programs to be
2141 found.
2142  
2143 =back
2144  
2145 =over 4
2146  
2147 =item config-perl
2148  
2149 ---
2150 perl:
2151 perl: perl
2152  
2153 The configuration file's C<perl> section provides the dynamic perl tasks which
2154 can serve as tasks with default commands (with options) and which can be
2155 recursively resolved and expanded.
2156  
2157 =back
2158  
2159 =over 4
2160  
2161 =item config-task
2162  
2163 ---
2164 task:
2165 setup: $PERL -MMyApp::Task::Setup -E0 --
2166  
2167 The configuration file's C<task> section provides the dynamic perl tasks which
2168 "load" L<Venus::Task> derived packages, and which can be recursively resolved
2169 and expanded. These tasks will typically take the form of C<perl -Ilib
2170 -MMyApp::Task -E0 --> and will be automatically executed as a CLI.
2171  
2172 =back
2173  
2174 =over 4
2175  
2176 =item config-vars
2177  
2178 ---
2179 vars:
2180 PERL: perl
2181  
2182 The configuration file's C<vars> section provides a list of dynamic key/value
2183 pairs that can be recursively resolved and expanded and will be used as
2184 environment variables.
2185  
2186 =back
2187  
2188 =over 4
2189  
2190 =item config-when
2191  
2192 ---
2193 when:
2194 is_lin:
2195 data:
2196 OSNAME: LINUX
2197 is_win:
2198 data:
2199 OSNAME: WINDOWS
2200  
2201 The configuration file's C<when> section provides a configuration tree to be
2202 merged with the existing configuration based on the name current operating
2203 system. The C<is_$name> key should correspond to one of the types specified by
2204 L<Venus::Os/type>.
2205  
2206 =back
2207  
2208 =over 4
2209  
2210 =item config-with
2211  
2212 ---
2213 with:
2214 psql: ./psql-tools/.vns.yml
2215  
2216 The configuration file's C<with> section provides a list of static key/value
2217 pairs where the key is the "subcommand" passed to the runner as the first
2218 arugment, and the value is the configuration file where the subcommand task
2219 definitions are defined which the runner dispatches to.
2220  
2221 =back
2222  
2223 =over 4
2224  
2225 =item vns-cli
2226  
2227 Here are example usages of the configuration file mentioned, executed by the
2228 L<vns> CLI, which is simply an executable file which loads this package.
2229  
2230 # Mint a new configuration file
2231 vns init
2232  
2233 ...
2234  
2235 # Mint a new JSON configuration file
2236 VENUS_FILE=.vns.json vns init
2237  
2238 # Mint a new YAML configuration file
2239 VENUS_FILE=.vns.yaml vns init
2240  
2241 ...
2242  
2243 # Install a distribution
2244 vns cpan $DIST
2245  
2246 # i.e.
2247 # cpanm --llocal -qn $DIST
2248  
2249 # Check that a package can be compiled
2250 vns okay $FILE
2251  
2252 # i.e.
2253 # perl -Ilib -Ilocal/lib/perl5 -c $FILE
2254  
2255 # Use the Perl debugger as a REPL
2256 vns repl
2257  
2258 # i.e.
2259 # perl -Ilib -Ilocal/lib/perl5 -dE0
2260  
2261 # Evaluate arbitrary Perl expressions
2262 vns exec ...
2263  
2264 # i.e.
2265 # perl -Ilib -Ilocal/lib/perl5 -MVenus=log -E $@
2266  
2267 # Test the Perl project in the CWD
2268 vns test t
2269  
2270 # i.e.
2271 # prove -Ilib -Ilocal/lib/perl5 t
2272  
2273 =back
2274  
2275 =head1 AUTHORS
2276  
2277 Awncorp, C<awncorp@cpan.org>
2278  
2279 =cut
2280  
2281 =head1 LICENSE
2282  
2283 Copyright (C) 2000, Awncorp, C<awncorp@cpan.org>.
2284  
2285 This program is free software, you can redistribute it and/or modify it under
2286 the terms of the Apache license version 2.0.
2287  
2288 =cut