Method: CommandKit::Options::OptionValue.default_usage

Defined in:
lib/command_kit/options/option_value.rb

.default_usage(type) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the default option value usage for the given type.

Parameters:

  • type (Class, Hash, Array, Regexp)

    The option value type.

Returns:

  • (String, nil)

    A default usage string based on the option value type.

Raises:

  • (TypeError)

    The given type was not a Class, Hash, Array, or Regexp.



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/command_kit/options/option_value.rb', line 92

def self.default_usage(type)
  USAGES.fetch(type) do
    case type
    when Class  then Inflector.underscore(type.name).upcase
    when Hash   then type.keys.join('|')
    when Array  then type.join('|')
    when Regexp then type.source
    else
      raise(TypeError,"unsupported option type: #{type.inspect}")
    end
  end
end