| 1 | package Net::SSH::Perl::Util::Term; | ||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | sub _prompt { | ||||||||||
| 6 | 0 | ▶ | my($prompt, $def, $echo) = @_; | ||||||||
|
Subroutine
_prompt: not called CC=4 SCAR=30.0
| |||||||||||
| 7 | 0 | ▶ | unless ($echo) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 8 | 0 | return _read_passphrase($prompt); | |||||||||
| 9 | } | ||||||||||
| 10 | else { | ||||||||||
| 11 | 0 | ▶ | print $prompt . ($def ? "[$def] " : ""); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 0 | chomp(my $ans = <STDIN>); | |||||||||
| 13 | 0 | ▶ | return $ans ? $ans : $def; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | } | ||||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | sub _read_passphrase { | ||||||||||
| 18 | 0 | ▶ | my($prompt) = @_; | ||||||||
|
Subroutine
_read_passphrase: not called CC=1 SCAR=6.9
| |||||||||||
| 19 | 0 | print $prompt; | |||||||||
| 20 | 0 | require Term::ReadKey; | |||||||||
| 21 | 0 | Term::ReadKey->import; | |||||||||
| 22 | 0 | ReadMode('noecho'); | |||||||||
| 23 | 0 | chomp(my $pwd = ReadLine(0)); | |||||||||
| 24 | 0 | ReadMode('restore'); | |||||||||
| 25 | 0 | print "\n"; | |||||||||
| 26 | 0 | $pwd; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | sub _read_yes_or_no { | ||||||||||
| 30 | 0 | ▶ | my($prompt, $def) = @_; | ||||||||
|
Subroutine
_read_yes_or_no: not called CC=2 SCAR=17.9
| |||||||||||
| 31 | 0 | print $prompt, " [$def] "; | |||||||||
| 32 | 0 | chomp(my $ans = <STDIN>); | |||||||||
| 33 | 0 | ▶ | $ans = $def unless $ans; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | $ans =~ /^y/i; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 5 | 1; | |||||||||