Method: Thor.map

Defined in:
lib/thor.rb

.map(mappings = nil) ⇒ 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.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/thor.rb', line 91

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

  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

Comments