Method: Thor.map

Defined in:
lib/thor.rb

.map(mappings = nil) ⇒ Object

Maps an input to a task. If you define:

map "-T" => "list"

Running:

thor -T

Will invoke the list task.

Parameters

Hash[String|Array => Symbol]

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



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/thor.rb', line 83

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