|
Revision 14903, 0.8 kB
(checked in by tokuhirom, 5 years ago)
|
|
added \n.
|
| Line | |
|---|
| 1 | package Archer::Plugin::Confirm; |
|---|
| 2 | use strict; |
|---|
| 3 | use warnings; |
|---|
| 4 | use base qw/Archer::Plugin/; |
|---|
| 5 | use IO::Prompt; |
|---|
| 6 | |
|---|
| 7 | sub run { |
|---|
| 8 | my ($self,) = @_; |
|---|
| 9 | |
|---|
| 10 | local $SIG{ALRM} = sub { |
|---|
| 11 | $self->detach("\n\nConfirm timeout\n"); |
|---|
| 12 | }; |
|---|
| 13 | |
|---|
| 14 | my $msg = $self->{config}->{msg} || 'do ? [y/n]'; |
|---|
| 15 | my $timeout = $self->{config}->{timeout} || 0; |
|---|
| 16 | my $latest_alarm = alarm $timeout; |
|---|
| 17 | |
|---|
| 18 | if ( IO::Prompt::prompt( $msg, '-yn' ) ) { |
|---|
| 19 | alarm $latest_alarm; |
|---|
| 20 | $self->log(debug => "yes"); |
|---|
| 21 | } |
|---|
| 22 | else { |
|---|
| 23 | $self->log(debug => "no"); |
|---|
| 24 | $self->detach("cancel'd by user"); |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | 1; |
|---|
| 29 | __END__ |
|---|
| 30 | |
|---|
| 31 | =head1 NAME |
|---|
| 32 | |
|---|
| 33 | Archer::Plugin::Confirm - |
|---|
| 34 | |
|---|
| 35 | =head1 SYNOPSIS |
|---|
| 36 | |
|---|
| 37 | - module: Confirm |
|---|
| 38 | config: |
|---|
| 39 | msg: really deploy? [Y/N] |
|---|
| 40 | |
|---|
| 41 | =head1 DESCRIPTION |
|---|
| 42 | |
|---|
| 43 | really deploy? |
|---|
| 44 | |
|---|
| 45 | =head1 AUTHORS |
|---|
| 46 | |
|---|
| 47 | Tokuhiro Matsuno. |
|---|
| 48 | |
|---|
| 49 | =cut |
|---|
| 50 | |
|---|