line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package urpm::prompt; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
915
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
270
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
0
|
|
|
0
|
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
|
|
|
|
|
|
|
sub write { |
17
|
0
|
|
|
0
|
0
|
|
my (undef, $msg) = @_; |
18
|
0
|
|
|
|
|
|
print STDOUT $msg; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub prompt { |
22
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
23
|
0
|
|
|
|
|
|
my @answers; |
24
|
0
|
|
|
|
|
|
$self->write($self->{title}); |
25
|
0
|
|
|
|
|
|
foreach my $i (0 .. $#{$self->{prompts}}) { |
|
0
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$self->write($self->{prompts}[$i]); |
27
|
0
|
0
|
|
|
|
|
$self->{hidden}[$i] and system("/bin/stty", "-echo"); |
28
|
0
|
|
|
|
|
|
my $input = ; |
29
|
0
|
0
|
|
|
|
|
$self->{hidden}[$i] and do { system("/bin/stty", "echo"); $self->write("\n") }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
defined $input or return @answers; |
31
|
0
|
|
|
|
|
|
chomp $input; |
32
|
0
|
0
|
|
|
|
|
$input eq '' and $input = defined $self->{defaults}[$i] ? $self->{defaults}[$i] : ''; |
|
|
0
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
push @answers, $input; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
@answers; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
=cut |