Skip to content

Commit

Permalink
Extract helper method for error report in cli/accounts command (#25119)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored and pull[bot] committed Jan 15, 2024
1 parent c93088e commit 3157418
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/mastodon/cli/accounts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@ def create(username)
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
Expand Down Expand Up @@ -189,12 +184,7 @@ def modify(username)
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
Expand Down Expand Up @@ -661,6 +651,14 @@ def migrate(username)

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)
Expand Down

0 comments on commit 3157418

Please sign in to comment.