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.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/bundler/vendor/thor/lib/thor.rb', line 93

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