Exception: Homebrew::CLI::MaxNamedArgumentsError Private

Inherits:
UsageError show all
Defined in:
cli/error.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Instance Attribute Summary

Attributes inherited from UsageError

#reason

Instance Method Summary collapse

Constructor Details

#initialize(maximum, types: []) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • maximum (Integer)
  • types (Array<Symbol>) (defaults to: [])


37
38
39
40
41
42
43
44
45
46
47
48
# File 'cli/error.rb', line 37

def initialize(maximum, types: [])
  super case maximum
  when 0
    "This command does not take named arguments."
  else
    types << :named if types.empty?
    arg_types = types.map { |type| type.to_s.tr("_", " ") }
                     .to_sentence two_words_connector: " or ", last_word_connector: " or "

    "This command does not take more than #{maximum} #{arg_types} #{Utils.pluralize("argument", maximum)}."
  end
end