lib/Chj/IO/Command.pm

filter: Statementstmt 39.0% 25 / 64 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 46.6% 7 / 15 Podpod 0.0% 0 / 8 totaltotal 35.9% 32 / 89 CC 2 SCAR 7.2
CC
2
Cov
38%
assume_with_maybe_stdin_stdout_stderr
6.0
new_out
2.0
new_in
2.0
CRAP 2.1
« lib/FP/Carp.pm ↑ Summary .htmlgen/FunctionalPerl/Htmlgen/PathTranslate.pm »
1 #
2 # Copyright (c) 2007-2022 Christian Jaeger, copying@christianjaeger.ch
3 #
4 # This is free software, offered under either the same terms as perl 5
5 # or the terms of the Artistic License version 2 or the terms of the
6 # MIT License (Expat version). See the file COPYING.md that came
7 # bundled with this file.
8 #
9  
10 # Depends: ()
11  
12 =head1 NAME
13  
14 Chj::IO::Command
15  
16 =head1 SYNOPSIS
17  
18 use Chj::IO::Command;
19 # my $mail = Chj::IO::Command->new_out("sendmail","-t"); or:
20 # my $mail = Chj::IO::Command->new_writer("sendmail","-t"); or:
21 my $mail = Chj::IO::Command->new_receiver("sendmail","-t");
22 warn "sendmail has pid ".$mail->pid;
23 $mail->xprint("From:..\nTo:..\n\n...");
24 my $exitcode = $mail->xfinish;
25 # my $date = Chj::IO::Command->new_in("date")->xcontent;
26 # my $date = Chj::IO::Command->new_reader("date")->xcontent;
27 my $date = Chj::IO::Command->new_sender("date")->xcontent;
28 # there's also ->new_err, which allows to gather errors
29  
30 # or catch stdout and stderr both together:
31 my $str = Chj::IO::Command->new_combinedsender("foo","bar","baz")->xcontent;
32  
33  
34 =head1 DESCRIPTION
35  
36 Launches external commands with input or output pipes.
37 Inherits from Chj::IO::Pipe.
38  
39 There is no support for multiple pipes to the same process.
40  
41 =head1 NOTE
42  
43 'new_in' does mean input from the view of the main process. May be a
44 bit confusing, since it's stdout of the subprocess. Same thing for
45 'new_out'. Maybe the aliases 'new_reader' and 'new_writer' are a bit
46 less confusing (true?).
47  
48 =head1 SEE ALSO
49  
50 L<Chj::IO::CommandBidirectional>, L<Chj::IO::CommandCommon>, L<Chj::IO::Pipe>,
51 L<Chj::IO::CommandStandalone>
52  
53 =head1 NOTE
54  
55 This is alpha software! Read the status section in the package README
56 or on the L<website|http://functional-perl.org/>.
57  
58 =cut
59  
60 package Chj::IO::Command;
61  
62 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 3 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
65  
66 3 ▶use base qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
67 Chj::IO::CommandCommon
68 Chj::IO::Pipe
69 IO
70 3 );
71 9 ▶sub import { }
Subroutine import: called CC=1 SCAR=0.0
72  
73 3 ▶use Chj::xpipe;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 3 ▶use FP::Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
75  
76 0 ▶sub new_out {
Subroutine new_out: not called CC=1 SCAR=6.9
Pod undocumented
77 0 my $class = shift;
78 0 my ($r, $self) = xpipe;
79 0 bless $self, $class;
80 0 $self->xlaunch($r, 0, @_)
81 }
82 3 *new_writer = \&new_out;
83 3 *new_write = \&new_out;
84 3 *new_receiver = \&new_out;
85  
86 0 ▶sub new_in {
Subroutine new_in: not called CC=1 SCAR=6.9
Pod undocumented
87 0 my $class = shift;
88 0 my ($self, $w) = xpipe;
89 0 bless $self, $class;
90 0 $self->xlaunch($w, 1, @_)
91 }
92 3 *new_reader = \&new_in;
93 3 *new_read = \&new_in;
94 3 *new_sender = \&new_in;
95  
96 0 ▶sub new_combinedsender {
Subroutine new_combinedsender: not called CC=1 SCAR=6.9
Pod undocumented
97 0 my $class = shift;
98 0 my ($self, $w) = xpipe;
99 0 bless $self, $class;
100 0 $self->xlaunch3(undef, $w, $w, @_)
101 }
102  
103 0 ▶sub new_combinedsender_with_stdin {
Subroutine new_combinedsender_with_stdin: not called CC=1 SCAR=6.9
Pod undocumented
104 0 my $class = shift;
105 0 my $stdin = shift;
106 0 my ($self, $w) = xpipe;
107 0 bless $self, $class;
108 0 $self->xlaunch3($stdin, $w, $w, @_)
109 }
110  
111 0 ▶sub assume_with_maybe_stdin_stdout_stderr {
Subroutine assume_with_maybe_stdin_stdout_stderr: not called CC=2 SCAR=17.9
Pod undocumented
112 0 my $class = shift;
113 0 ▶ @_ > 4 or fp_croak_arity "> 4";
Branch: 1 branch
BranchTrueFalseTotal
@_ > 4 or fp_croak_arity("> 4") 0 0 0
114 0 my $self = shift;
115 0 my $in = shift;
116 0 my $out = shift;
117 0 my $err = shift;
118 0 bless $self, $class;
119 0 $self->xlaunch3($in, $out, $err, @_)
120 }
121  
122 0 ▶sub new_err {
Subroutine new_err: not called CC=1 SCAR=6.9
Pod undocumented
123 0 my $class = shift;
124 0 my ($self, $w) = xpipe;
125 0 bless $self, $class;
126 0 $self->xlaunch($w, 2, @_);
127 }
128  
129 0 ▶sub new_receiver_with_stderr_to_fh {
Subroutine new_receiver_with_stderr_to_fh: not called CC=1 SCAR=6.9
Pod undocumented
130 0 my $class = shift;
131 0 my $errfh = shift;
132 0 my ($r, $self) = xpipe;
133 0 bless $self, $class;
134 0 $self->xlaunch3($r, undef, $errfh, @_)
135 }
136  
137 0 ▶sub new_receiver_with_stdout_to_fh {
Subroutine new_receiver_with_stdout_to_fh: not called CC=1 SCAR=6.9
Pod undocumented
138 0 my $class = shift;
139 0 my $outfh = shift;
140 0 my ($r, $self) = xpipe;
141 0 bless $self, $class;
142 0 $self->xlaunch3($r, $outfh, undef, @_)
143 }
144  
145 3 1
« lib/FP/Carp.pm ↑ Summary .htmlgen/FunctionalPerl/Htmlgen/PathTranslate.pm »