Skip to content

Commit

Permalink
removing option "--yes"
Browse files Browse the repository at this point in the history
  • Loading branch information
bodo-hugo-barwich committed Dec 10, 2021
1 parent 55883c1 commit 7f4d72b
Showing 1 changed file with 19 additions and 39 deletions.
58 changes: 19 additions & 39 deletions lib/MetaCPAN/Role/Script.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,14 @@ has exit_code => (
);

has arg_await_timeout => (
init_arg => 'await',
is => 'ro',
isa => Int,
default => 15,
init_arg => 'await',
is => 'ro',
isa => Int,
default => 15,
documentation =>
'seconds before connection is considered failed with timeout',
);

has arg_yes => (
init_arg => 'yes',
is => 'ro',
isa => Bool,
default => 0,
documentation => 'automatically accept all operations',
);

has ua => (
is => 'ro',
lazy => 1,
Expand Down Expand Up @@ -87,10 +79,10 @@ has model => (
);

has index => (
reader => '_index',
is => 'ro',
isa => Str,
default => 'cpan',
reader => '_index',
is => 'ro',
isa => Str,
default => 'cpan',
documentation =>
'Index to use, defaults to "cpan" (when used: also export ES_SCRIPT_INDEX)',
);
Expand Down Expand Up @@ -267,7 +259,7 @@ sub check_health {
my $sinfo_rs
= $self->es->cat->indices( h => [ 'index', 'health' ] );

$self->indices_info({});
$self->indices_info( {} );

while ( $sinfo_rs =~ /^([^[:space:]]+) +([^[:space:]]+)/gm ) {
$self->indices_info->{$1}
Expand All @@ -289,7 +281,7 @@ sub check_health {
my $sinfo_rs
= $self->es->cat->aliases( h => [ 'alias', 'index' ] );

$self->aliases_info({});
$self->aliases_info( {} );

while ( $sinfo_rs =~ /^([^[:space:]]+) +([^[:space:]]+)/gm ) {
$self->aliases_info->{$1}
Expand Down Expand Up @@ -349,7 +341,7 @@ sub await {

#Set System Error: 112 - EHOSTDOWN - Host is down
$self->exit_code(112);
$self->handle_error($@, 1);
$self->handle_error( $@, 1 );
}
}
} while ( !$iready && $iseconds <= $self->arg_await_timeout );
Expand All @@ -365,20 +357,15 @@ sub await {
sub are_you_sure {
my ( $self, $msg ) = @_;

unless ( $self->arg_yes ) {
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) ? ';
if ( $answer ne 'YES' ) {
print "bye.\n";
exit 0;
}
print "alright then...\n";
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) ? ';
if ( $answer ne 'YES' ) {
print "bye.\n";
exit 0;
}
}
else {
print colored( ['yellow'], "Notice: $msg" ), "\n";
print "alright then...\n";
}
}

Expand Down Expand Up @@ -412,13 +399,6 @@ After C<await> seconds the Application will fail with an Exception and the Exit
See L<Method C<await()>>
=item Option C<--yes>
This option will automatically accept all operations. In C<are_you_sure()> it will not show the warning.
It will show the message as notice instead.
bin/metacpan <script_name> --yes
=back
=head1 METHODS
Expand Down

0 comments on commit 7f4d72b

Please sign in to comment.