From cd4f0feab89af1ff9b1e18a8640b4bcab915cb1d Mon Sep 17 00:00:00 2001
From: Matt Jankowski <matt@jankowski.online>
Date: Thu, 1 Jun 2023 08:35:05 -0400
Subject: [PATCH] Extract verify options method in search cli (#25121)

---
 lib/mastodon/cli/search.rb | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/lib/mastodon/cli/search.rb b/lib/mastodon/cli/search.rb
index 6f48dcb09..8d7b7202f 100644
--- a/lib/mastodon/cli/search.rb
+++ b/lib/mastodon/cli/search.rb
@@ -29,15 +29,7 @@ module Mastodon::CLI
       database will be imported into the indices, unless overridden with --no-import.
     LONG_DESC
     def deploy
-      if options[:concurrency] < 1
-        say('Cannot run with this concurrency setting, must be at least 1', :red)
-        exit(1)
-      end
-
-      if options[:batch_size] < 1
-        say('Cannot run with this batch_size setting, must be at least 1', :red)
-        exit(1)
-      end
+      verify_deploy_options!
 
       indices = if options[:only]
                   options[:only].map { |str| "#{str.camelize}Index".constantize }
@@ -98,5 +90,26 @@ module Mastodon::CLI
 
       say("Indexed #{added} records, de-indexed #{removed}", :green, true)
     end
+
+    private
+
+    def verify_deploy_options!
+      verify_deploy_concurrency!
+      verify_deploy_batch_size!
+    end
+
+    def verify_deploy_concurrency!
+      return unless options[:concurrency] < 1
+
+      say('Cannot run with this concurrency setting, must be at least 1', :red)
+      exit(1)
+    end
+
+    def verify_deploy_batch_size!
+      return unless options[:batch_size] < 1
+
+      say('Cannot run with this batch_size setting, must be at least 1', :red)
+      exit(1)
+    end
   end
 end