line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
1292
|
use 5.008008; |
|
3
|
|
|
|
|
10
|
|
2
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
91
|
|
3
|
3
|
|
|
3
|
|
24
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
213
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Ask::STDIO; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.015'; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
31
|
use Moo; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
16
|
|
11
|
3
|
|
|
3
|
|
947
|
use namespace::autoclean; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
17
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
with 'Ask::API'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub is_usable { |
16
|
0
|
|
|
0
|
0
|
0
|
my ( $self ) = @_; |
17
|
0
|
0
|
|
|
|
0
|
-t STDIN and -t STDOUT; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub quality { |
21
|
9
|
50
|
33
|
9
|
0
|
90
|
( -t STDIN and -t STDOUT ) ? 80 : 20; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub entry { |
25
|
0
|
|
|
0
|
0
|
|
my ( $self, %o ) = @_; |
26
|
0
|
0
|
|
|
|
|
$self->info( text => $o{text} ) if exists $o{text}; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my ( $line, $tio ); |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
0
|
|
|
|
if ( |
31
|
|
|
|
|
|
|
$o{hide_text} |
32
|
0
|
|
|
|
|
|
and do { require POSIX; $tio = 'POSIX::Termios'->new } |
|
0
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
) |
34
|
|
|
|
|
|
|
{ |
35
|
0
|
|
|
|
|
|
require POSIX; |
36
|
0
|
|
|
|
|
|
my $tio = POSIX::Termios->new; |
37
|
0
|
|
|
|
|
|
$tio->getattr( 0 ); |
38
|
0
|
|
|
|
|
|
$tio->setlflag( $tio->getlflag & ~POSIX::ECHO() ); |
39
|
0
|
|
|
|
|
|
$tio->setattr( 0 ); |
40
|
0
|
|
|
|
|
|
chomp( $line = ); |
41
|
0
|
|
|
|
|
|
$tio->setlflag( $tio->getlflag | POSIX::ECHO() ); |
42
|
0
|
|
|
|
|
|
$tio->setattr( 0 ); |
43
|
|
|
|
|
|
|
} #/ if ( $o{hide_text} and...) |
44
|
|
|
|
|
|
|
else { |
45
|
0
|
|
|
|
|
|
chomp( $line = ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return $line; |
49
|
|
|
|
|
|
|
} #/ sub entry |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub info { |
52
|
0
|
|
|
0
|
0
|
|
my ( $self, %o ) = @_; |
53
|
0
|
|
|
|
|
|
print STDOUT "$o{text}\n"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub warning { |
57
|
0
|
|
|
0
|
0
|
|
my ( $self, %o ) = @_; |
58
|
0
|
|
|
|
|
|
print STDERR "WARNING: $o{text}\n"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub error { |
62
|
0
|
|
|
0
|
0
|
|
my ( $self, %o ) = @_; |
63
|
0
|
|
|
|
|
|
print STDERR "ERROR: $o{text}\n"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |