Method: Bundler::Thor.map

Defined in:
lib/bundler/vendor/thor/lib/thor.rb

.map(mappings = nil, **kw) ⇒ Object

Maps an input to a command. If you define:

map "-T" => "list"

Running:

thor -T

Will invoke the list command.

Parameters

Hash[String|Array => Symbol]

Maps the string or the strings in the array to the given command.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/bundler/vendor/thor/lib/thor.rb', line 101

def map(mappings = nil, **kw)
  @map ||= from_superclass(:map, {})

  if mappings && !kw.empty?
    mappings = kw.merge!(mappings)
  else
    mappings ||= kw
  end
  if mappings
    mappings.each do |key, value|
      if key.respond_to?(:each)
        key.each { |subkey| @map[subkey] = value }
      else
        @map[key] = value
      end
    end
  end

  @map
end