From b7b96efd17bfcabad56730bdf48650fb93f34fc9 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 30 May 2023 10:09:15 -0400 Subject: [PATCH] Extract helper method for error report in cli/accounts command (#25119) --- lib/mastodon/cli/accounts.rb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/mastodon/cli/accounts.rb b/lib/mastodon/cli/accounts.rb index fd8368565..33520df25 100644 --- a/lib/mastodon/cli/accounts.rb +++ b/lib/mastodon/cli/accounts.rb @@ -113,12 +113,7 @@ module Mastodon::CLI say('OK', :green) say("New password: #{password}") else - user.errors.each do |error| - say('Failure/Error: ', :red) - say(error.attribute) - say(" #{error.type}", :red) - end - + report_errors(user.errors) exit(1) end end @@ -189,12 +184,7 @@ module Mastodon::CLI say('OK', :green) say("New password: #{password}") if options[:reset_password] else - user.errors.each do |error| - say('Failure/Error: ', :red) - say(error.attribute) - say(" #{error.type}", :red) - end - + report_errors(user.errors) exit(1) end end @@ -661,6 +651,14 @@ module Mastodon::CLI private + def report_errors(errors) + errors.each do |error| + say('Failure/Error: ', :red) + say(error.attribute) + say(" #{error.type}", :red) + end + end + def rotate_keys_for_account(account, delay = 0) if account.nil? say('No such account', :red)