Remote/Prompt.pm

filter: Statementstmt 39.4% 15 / 38 Branchbran 11.1% 2 / 18 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 40.0% 4 / 10 Podpod 0.0% 0 / 4 totaltotal 28.0% 21 / 75 CC 10 SCAR 31.2
CC
10
Cov
29%
_local_prompt_core
56.0
prompt
6.0
prompt_pw
6.0
CRAP 22.7
« Remote/Connector/LocalSudo.pm ↑ Summary Remote/Logging.pm »
1 package Object::Remote::Prompt;
2  
3 11 ▶use strictures 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 our @EXPORT = qw(prompt prompt_pw);
8  
9 11 our ($prompt, $prompt_pw);
10  
11 0 ▶sub _local_prompt {
Subroutine _local_prompt: not called CC=1 SCAR=6.9
12 0 _local_prompt_core(0, @_);
13 }
14  
15 0 ▶sub _local_prompt_pw {
Subroutine _local_prompt_pw: not called CC=1 SCAR=6.9
16 0 _local_prompt_core(1, @_);
17 }
18  
19 11 our %Prompt_Cache;
20  
21 0 ▶sub _local_prompt_core {
Subroutine _local_prompt_core: not called CC=7 SCAR=40.3
22 0 my ($pw, $message, $default, $opts) = @_;
23  
24 0 ▶ if ($opts->{cache} and my $hit = $Prompt_Cache{$message}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"cache"} and my $hit = $Object::Remote::Prompt::Prompt_Cache{$message}) 0 0 0
Condition0%0/3
$opts->{"cache"} and my $hit = $Object::Remote::Prompt::Prompt_Cache{$message}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"cache"} and my $hit = $Object::Remote::Prompt::Prompt_Cache{$message}
$opts->{"cache"} my $hit = $Object::Remote::Prompt::Prompt_Cache{$message}
Truth table0%0/3
A and B
A= $opts->{"cache"}B= my $hit = $Object::Remote::Prompt::Prompt_Cache{$message}
ABresult
0X0
100
111
25 0 return $hit;
26 }
27  
28 0 STDOUT->autoflush(1);
29  
30 0 ▶ system('stty -echo') if $pw;
Branch: 1 branch
BranchTrueFalseTotal
if $pw 0 0 0
31  
32 0 print STDOUT "${message}: ";
33 0 chomp(my $res = <STDIN>);
34  
35 0 ▶ print STDOUT "\n" if $pw;
Branch: 1 branch
BranchTrueFalseTotal
if $pw 0 0 0
36 0 ▶ system('stty echo') if $pw;
Branch: 1 branch
BranchTrueFalseTotal
if $pw 0 0 0
37  
38 0 ▶ $Prompt_Cache{$message} = $res if $opts->{cache};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"cache"} 0 0 0
39  
40 0 return $res;
41 }
42  
43 0 ▶sub prompt {
Subroutine prompt: not called CC=2 SCAR=17.9
Pod undocumented
44 0 ▶ die "User input wanted - $_[0] - but no prompt available"
Branch: 1 branch
BranchTrueFalseTotal
unless $Object::Remote::Prompt::prompt 0 0 0
45 unless $prompt;
46 0 goto &$prompt;
47 }
48  
49 0 ▶sub prompt_pw {
Subroutine prompt_pw: not called CC=2 SCAR=17.9
Pod undocumented
50 0 ▶ die "User input wanted - $_[0] - but no password prompt available"
Branch: 1 branch
BranchTrueFalseTotal
unless $Object::Remote::Prompt::prompt_pw 0 0 0
51 unless $prompt_pw;
52 0 goto &$prompt_pw;
53 }
54  
55 11 ▶if (-t STDIN) {
Branch: 1 branch
BranchTrueFalseTotal
if (-t STDIN) 0 11 11
56 0 $prompt = \&_local_prompt;
57 0 $prompt_pw = \&_local_prompt_pw;
58 }
59  
60 0 ▶sub set_local_prompt_command {
Subroutine set_local_prompt_command: not called CC=1 SCAR=6.9
Pod undocumented
61 0 ($prompt, $prompt_pw) = @_;
62 0 return;
63 }
64  
65 19 ▶sub maybe_set_prompt_command_on {
Subroutine maybe_set_prompt_command_on: called CC=2 SCAR=10.5
Pod undocumented
66 19 ▶ return unless $prompt;
Branch: 1 branch
BranchTrueFalseTotal
unless $Object::Remote::Prompt::prompt 19 0 19
67 0 my ($conn) = @_;
68 0 $conn->remote_sub('Object::Remote::Prompt::set_local_prompt_command')
69 ->($prompt, $prompt_pw);
70 }
71  
72 11 1;
« Remote/Connector/LocalSudo.pm ↑ Summary Remote/Logging.pm »