Method: Thor::Base::ClassMethods#find_and_refresh_command

Defined in:
lib/thor/base/class_methods.rb

#find_and_refresh_command(name) ⇒ Object (protected) Also known as: find_and_refresh_task

Finds a command with the given name. If the command belongs to the current class, just return it, otherwise dup it and add the fresh copy to the current command hash.



538
539
540
541
542
543
544
545
546
547
548
# File 'lib/thor/base/class_methods.rb', line 538

def find_and_refresh_command(name) #:nodoc:
  if commands[name.to_s]
    commands[name.to_s]
  elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
    commands[name.to_s] = command.clone
  else
    raise ArgumentError,
      "You supplied :for => #{name.inspect}, but the command " \
      "#{name.inspect} could not be found."
  end
end