root/lang/perl/Archer/trunk/lib/Archer/Plugin/Confirm.pm @ 14903

Revision 14903, 0.8 kB (checked in by tokuhirom, 5 years ago)

added \n.

Line 
1package Archer::Plugin::Confirm;
2use strict;
3use warnings;
4use base qw/Archer::Plugin/;
5use IO::Prompt;
6
7sub 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
281;
29__END__
30
31=head1 NAME
32
33Archer::Plugin::Confirm -
34
35=head1 SYNOPSIS
36
37  - module: Confirm
38    config:
39      msg: really deploy? [Y/N]
40
41=head1 DESCRIPTION
42
43really deploy?
44
45=head1 AUTHORS
46
47Tokuhiro Matsuno.
48
49=cut
50
Note: See TracBrowser for help on using the browser.