urpm/prompt.pm

filter: Statementstmt 16.6% 4 / 24 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 1 / 4 Podpod 0.0% 0 / 3 totaltotal 12.2% 5 / 41 CC 7 SCAR 36.8
CC
7
Cov
12%
prompt
56.0
new
2.0
write
2.0
CRAP 39.7
↑ Summary urpm/util.pm »
1 package urpm::prompt;
2  
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
7 0 my ($class, $title, $prompts, $defaults, $hidden) = @_;
8 0 bless {
9 title => $title,
10 prompts => $prompts,
11 defaults => $defaults,
12 hidden => $hidden,
13 }, $class;
14 }
15  
16 0 ▶sub write {
Subroutine write: not called CC=1 SCAR=6.9
Pod undocumented
17 0 my (undef, $msg) = @_;
18 0 print STDOUT $msg;
19 }
20  
21 0 ▶sub prompt {
Subroutine prompt: not called CC=7 SCAR=40.3
Pod undocumented
22 0 my ($self) = @_;
23 0 my @answers;
24 0 $self->write($self->{title});
25 0 foreach my $i (0 .. $#{$self->{prompts}}) {
26 0 $self->write($self->{prompts}[$i]);
27 0 ▶ $self->{hidden}[$i] and system("/bin/stty", "-echo");
Branch: 1 branch
BranchTrueFalseTotal
$self->{"hidden"}[$i] and system "/bin/stty", "-echo" 0 0 0
28 0 my $input = <STDIN>;
29 0 ▶ $self->{hidden}[$i] and do { system("/bin/stty", "echo"); $self->write("\n") };
Branch: 1 branch
BranchTrueFalseTotal
$self->{"hidden"}[$i] and do { system "/bin/stty", "echo"; $self->write("\n") } 0 0 0
30 0 ▶ defined $input or return @answers;
Branch: 1 branch
BranchTrueFalseTotal
defined $input or return @answers 0 0 0
31 0 chomp $input;
32 0 ▶ $input eq '' and $input = defined $self->{defaults}[$i] ? $self->{defaults}[$i] : '';
Branch: 2 branches
BranchTrueFalseTotal
$input eq "" and $input = defined $self->{"defaults"}[$i] ? $self->{"defaults"}[$i] : "" 0 0 0
defined $self->{'defaults'}[$i] ? : 0 0 0
33 0 push @answers, $input;
34 }
35 0 @answers;
36 }
37  
38 1 1;
39  
40  
41 =head1 NAME
42  
43 urpm::prompt - base class to prompt the user for data
44  
45 =head1 SYNOPSIS
46  
47 =head1 DESCRIPTION
48  
49 =head1 COPYRIGHT
50  
51 Copyright (C) 2005 MandrakeSoft SA
52  
53 Copyright (C) 2005-2010 Mandriva SA
54  
55 Copyright (C) 2011-2020 Mageia
56  
57 =cut
↑ Summary urpm/util.pm »