| 1 | package Git::Deploy::Question; | ||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 1 | ▶ | use warnings FATAL => "all"; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 1 | ▶ | use Exporter 'import'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 1 | ▶ | use Term::ReadLine; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 1 | ▶ | use Git::Deploy::Say; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 1 | our @EXPORT = qw( | |||||||||||||
| 9 | _question | ||||||||||||||
| 10 | ); | ||||||||||||||
| 11 | |||||||||||||||
| 12 | 0 | ▶ | sub _question { | ||||||||||||
|
Subroutine
_question: not called CC=5 SCAR=34.0
| |||||||||||||||
| 13 | 0 | my %opts = ( | |||||||||||||
| 14 | question => "Continue anyway? [Y/n]", | ||||||||||||||
| 15 | answer_positive => qr/^Y(?:es)?/i, | ||||||||||||||
| 16 | answer_negative => qr/^N(?:o)?/i, | ||||||||||||||
| 17 | |||||||||||||||
| 18 | @_, # this goes last, for hobo default overriding | ||||||||||||||
| 19 | ); | ||||||||||||||
| 20 | |||||||||||||||
| 21 | 0 | my $term = Term::ReadLine->new($0); | |||||||||||||
| 22 | 0 | ▶ | while (defined (my $line = $term->readline("$opts{question}> "))) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | 0 | for ($line) { | |||||||||||||
| 24 | 0 | ▶ | if ( /$opts{answer_positive}/ ) { return 1 } | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 25 | 0 | elsif ( /$opts{answer_negative}/ ) { return 0 } | |||||||||||||
| 26 | else { | ||||||||||||||
| 27 | 0 | _warn "I can't understand you, try again\n"; | |||||||||||||
| 28 | } | ||||||||||||||
| 29 | } | ||||||||||||||
| 30 | } | ||||||||||||||
| 31 | } | ||||||||||||||
| 32 | |||||||||||||||
| 33 | 1 | 1; | |||||||||||||