diff --git a/lib/MetaCPAN/Role/Script.pm b/lib/MetaCPAN/Role/Script.pm index 102f80174..c8532597f 100644 --- a/lib/MetaCPAN/Role/Script.pm +++ b/lib/MetaCPAN/Role/Script.pm @@ -364,17 +364,32 @@ sub await { sub are_you_sure { my ( $self, $msg ) = @_; + my $iconfirmed = 0; if (is_interactive) { - print colored( ['bold red'], "*** Warning ***: $msg" ), "\n"; - my $answer = prompt - 'Are you sure you want to do this (type "YES" to confirm) ? '; + my $answer + = prompt colored( ['bold red'], "*** Warning ***: $msg" ) . "\n" + . 'Are you sure you want to do this (type "YES" to confirm) ? '; if ( $answer ne 'YES' ) { - print "bye.\n"; - exit 0; + log_error {"Confirmation incorrect: '$answer'"}; + print "Operation will be interruped!\n"; + + #Set System Error: 125 - ECANCELED - Operation canceled + $self->exit_code(125); + $self->handle_error( 'Operation canceled on User Request', 1 ); + } + else { + log_info {'Operation confirmed.'}; + print "alright then...\n"; + $iconfirmed = 1; } - print "alright then...\n"; } + else { + print colored( ['bold yellow'], "*** Warning ***: $msg" ) . "\n"; + $iconfirmed = 1; + } + + return $iconfirmed; } 1; @@ -405,6 +420,9 @@ After C seconds the Application will fail with an Exception and the Exit bin/metacpan --await 15 +B If the I service does not become available +within C seconds it exits the Script with Exit Code C< 112 >. + See L> =back @@ -421,11 +439,16 @@ This method uses the L|https://metacpan.org/pod/Search::Elasticsearch::Client::2_0::Direct#ping()> method to verify the service availabilty and wait for C seconds. When the service does not become available within C seconds it re-throws the -Exception from the C and sets C< $! > to C< 112 >. +Exception from the C and sets B to C< 112 >. The C generates a C<"Search::Elasticsearch::Error::NoNodes"> Exception. When the service is available it will populate the C C structure with the basic information about the cluster. + +B It will throw an exceptions when the I service does not become available +within C seconds (as described above). + See L