| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
3
|
|
|
3
|
|
1713
|
use 5.008008; |
|
|
3
|
|
|
|
|
13
|
|
|
2
|
3
|
|
|
3
|
|
18
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
73
|
|
|
3
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
163
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Ask::Clui; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
|
8
|
|
|
|
|
|
|
our $VERSION = '0.013'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
16
|
use Moo; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
26
|
|
|
11
|
3
|
|
|
3
|
|
3245
|
use Term::Clui 1.65 (); |
|
|
3
|
|
|
|
|
38056
|
|
|
|
3
|
|
|
|
|
108
|
|
|
12
|
3
|
|
|
3
|
|
22
|
use Path::Tiny 'path'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
3317
|
|
|
13
|
3
|
|
|
3
|
|
41
|
use namespace::autoclean; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Ask::API'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub BUILD { |
|
18
|
0
|
|
|
0
|
0
|
0
|
STDOUT->autoflush( 1 ); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub is_usable { |
|
22
|
0
|
|
|
0
|
0
|
0
|
my ( $self ) = @_; |
|
23
|
0
|
0
|
|
|
|
0
|
-t STDIN and -t STDOUT; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub quality { |
|
27
|
15
|
|
|
15
|
0
|
55
|
my ( $self ) = ( shift ); |
|
28
|
15
|
50
|
33
|
|
|
156
|
( -t STDIN and -t STDOUT ) ? 91 : 30; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub info { |
|
32
|
0
|
|
|
0
|
0
|
|
my ( $self, %opts ) = ( shift, @_ ); |
|
33
|
0
|
|
|
|
|
|
chomp( my $text = $opts{text} ); |
|
34
|
0
|
|
|
|
|
|
Term::Clui::inform( $opts{text} ); |
|
35
|
0
|
|
|
|
|
|
return; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub warning { |
|
39
|
0
|
|
|
0
|
0
|
|
my ( $self, %opts ) = ( shift, @_ ); |
|
40
|
0
|
|
|
|
|
|
chomp( my $text = $opts{text} ); |
|
41
|
0
|
|
|
|
|
|
Term::Clui::inform( 'WARNING: ' . $opts{text} ); |
|
42
|
0
|
|
|
|
|
|
return; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub error { |
|
46
|
0
|
|
|
0
|
0
|
|
my ( $self, %opts ) = ( shift, @_ ); |
|
47
|
0
|
|
|
|
|
|
chomp( my $text = $opts{text} ); |
|
48
|
0
|
|
|
|
|
|
Term::Clui::inform( 'ERROR: ' . $opts{text} ); |
|
49
|
0
|
|
|
|
|
|
return; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub entry { |
|
53
|
0
|
|
|
0
|
0
|
|
my ( $self, %opts ) = ( shift, @_ ); |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if ( $opts{hide_text} ) { |
|
56
|
0
|
|
|
|
|
|
return Term::Clui::ask_password( $opts{text} ); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
0
|
|
|
|
return Term::Clui::ask( $opts{text}, $opts{default} || '' ); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub question { |
|
63
|
0
|
|
|
0
|
0
|
|
my ( $self, %opts ) = ( shift, @_ ); |
|
64
|
0
|
|
|
|
|
|
chomp( my $text = $opts{text} ); |
|
65
|
0
|
|
|
|
|
|
return Term::Clui::confirm( $opts{text} ); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $_choices = sub { |
|
69
|
|
|
|
|
|
|
my $ref = shift; |
|
70
|
|
|
|
|
|
|
map $_->[0], @$ref; |
|
71
|
|
|
|
|
|
|
}; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub single_choice { |
|
74
|
0
|
|
|
0
|
0
|
|
my ( $self, %opts ) = ( shift, @_ ); |
|
75
|
0
|
|
|
|
|
|
local $ENV{CLUI_DIR} = 'OFF'; |
|
76
|
0
|
|
|
|
|
|
scalar Term::Clui::choose( $opts{text}, $_choices->( $opts{choices} ) ); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub multiple_choice { |
|
80
|
0
|
|
|
0
|
0
|
|
my ( $self, %opts ) = ( shift, @_ ); |
|
81
|
0
|
|
|
|
|
|
local $ENV{CLUI_DIR} = 'OFF'; |
|
82
|
0
|
|
|
|
|
|
Term::Clui::choose( $opts{text}, $_choices->( $opts{choices} ) ); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub file_selection { |
|
86
|
0
|
|
|
0
|
0
|
|
my ( $self, %opts ) = ( shift, @_ ); |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my @chosen; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
FILE: { |
|
91
|
0
|
|
|
|
|
|
my $got = Term::Clui::ask_filename( $opts{text} ); |
|
|
0
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
if ( not length $got ) { |
|
94
|
0
|
0
|
|
|
|
|
last FILE if $opts{multiple}; |
|
95
|
0
|
|
|
|
|
|
redo FILE; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$got = path $got; |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
0
|
0
|
|
|
|
if ( $opts{existing} and not $got->exists ) { |
|
101
|
0
|
|
|
|
|
|
$self->error( text => 'Does not exist.' ); |
|
102
|
0
|
|
|
|
|
|
redo FILE; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
0
|
0
|
|
|
|
if ( $opts{directory} and not $got->is_dir ) { |
|
106
|
0
|
|
|
|
|
|
$self->error( text => 'Is not a directory.' ); |
|
107
|
0
|
|
|
|
|
|
redo FILE; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
push @chosen, $got; |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
if ( $opts{multiple} ) { |
|
113
|
0
|
|
|
|
|
|
$self->info( text => 'Enter another file, or leave blank to finish.' ); |
|
114
|
0
|
|
|
|
|
|
redo FILE; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
} #/ FILE: |
|
117
|
|
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
|
$opts{multiple} ? @chosen : $chosen[0]; |
|
119
|
|
|
|
|
|
|
} #/ sub file_selection |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |