From 2ee30b8067128db2e07a12c786873262019402de Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 28 Sep 2020 01:24:55 +0200 Subject: [PATCH] Refactor `MinNamedArgumentsError` and `MaxNamedArgumentsError`. --- Library/Homebrew/cli/parser.rb | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index be94c98aa0..d1ee78f854 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -454,29 +454,18 @@ module Homebrew class MaxNamedArgumentsError < UsageError def initialize(maximum) - message = case maximum + super case maximum when 0 - "this command does not take named arguments" - when 1 - "this command does not take multiple named arguments" + "This command does not take named arguments." else - "this command does not take more than #{maximum} named arguments" + "This command does not take more than #{maximum} named #{"argument".pluralize(maximum)}" end - super message end end class MinNamedArgumentsError < UsageError def initialize(minimum) - message = case minimum - when 1 - "this command requires a named argument" - when 2 - "this command requires multiple named arguments" - else - "this command requires at least #{minimum} named arguments" - end - super message + super "This command requires at least #{minimum} named #{"argument".pluralize(minimum)}." end end end