| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::RemoteCommand::Util; | 
| 2 | 1 |  |  | 1 |  | 7 | use strict; | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 29 |  | 
| 3 | 1 |  |  | 1 |  | 13 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 26 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use Exporter 'import'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 114 |  | 
| 5 |  |  |  |  |  |  | our @EXPORT_OK = qw(prompt DEBUG logger); | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 1 | 50 |  | 1 |  | 10 | use constant DEBUG => $ENV{PERL_RCOMMAND_DEBUG} ? 1 : 0; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 140 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 549 | use Term::ReadKey 'ReadMode'; | 
|  | 1 |  |  |  |  | 2257 |  | 
|  | 1 |  |  |  |  | 286 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | sub logger { | 
| 12 | 0 | 0 |  | 0 | 0 |  | my $msg = @_ == 1 ? $_[0] : sprintf shift, @_; | 
| 13 | 0 |  |  |  |  |  | warn " | $msg\n"; | 
| 14 |  |  |  |  |  |  | } | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | sub prompt { | 
| 17 | 0 |  |  | 0 | 0 |  | my $msg = shift; | 
| 18 | 0 |  |  |  |  |  | local $| = 1; | 
| 19 | 0 |  |  |  |  |  | print $msg; | 
| 20 | 0 |  |  |  |  |  | ReadMode 'noecho', \*STDIN; | 
| 21 | 0 |  |  |  |  |  | my $SIGNAL = "Catch SIGINT\n"; | 
| 22 | 0 |  |  |  |  |  | my $answer; | 
| 23 | 0 |  |  |  |  |  | eval { | 
| 24 | 0 |  |  | 0 |  |  | local $SIG{INT} = sub { die $SIGNAL }; | 
|  | 0 |  |  |  |  |  |  | 
| 25 | 0 |  |  |  |  |  | $answer = ; | 
| 26 |  |  |  |  |  |  | }; | 
| 27 | 0 |  |  |  |  |  | my $error = $@; | 
| 28 | 0 |  |  |  |  |  | ReadMode 'restore', \*STDIN; | 
| 29 | 0 |  |  |  |  |  | print "\n"; | 
| 30 | 0 | 0 |  |  |  |  | die $error if $error; | 
| 31 | 0 |  |  |  |  |  | chomp $answer; | 
| 32 | 0 |  |  |  |  |  | $answer; | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | 1; |