OSDN Git Service

Commnand: bypass "-f" flag checking when test mode
authorhylom <hylom@users.sourceforge.jp>
Fri, 17 Aug 2018 11:00:14 +0000 (20:00 +0900)
committerhylom <hylom@users.sourceforge.jp>
Fri, 17 Aug 2018 11:00:14 +0000 (20:00 +0900)
src/newslash_web/lib/Newslash/Command.pm

index f5b1dff..8d85d1f 100644 (file)
@@ -21,11 +21,14 @@ sub check_force_option {
     }
 
     if ($self->danger) {
-        if (any { $_ !~ /^\s*-f\s*$/ } @$args) {
-            $self->app->log->error("This command is dangerous, so needs '-f' option.");
-            return;
+        my $mode = $self->app->mode;
+        if (!$mode || $mode ne "test") {
+            if (all { $_ !~ /^\s*-f\s*$/ } @$args) {
+                $self->app->log->error("This command is dangerous, so needs '-f' option under '$mode' mode.");
+                return;
+            }
+            @$args = grep { $_ !~ /^\s*-f\s*$/ } @$args;
         }
-        @$args = grep { $_ !~ /^\s*-f\s*$/ } @$args;
     }
 
     return 1;