Method: GitCommander::Registry#find

Defined in:
lib/git_commander/registry.rb

#find(command_name) ⇒ GitCommander::Command, #run

Looks up a command in the registry

Examples:

Fetch a command from the registry

registry = GitCommander::Registry.new
registry.register :wtf
registry.find :wtf

Parameters:

  • command_name (String, Symbol)

    the name of the command to look up in the registry

Returns:

Raises:



72
73
74
75
76
77
78
# File 'lib/git_commander/registry.rb', line 72

def find(command_name)
  GitCommander.logger.debug "[#{logger_tag}] looking up command: #{command_name.inspect}"
  command = commands[command_name.to_s.to_sym]
  raise CommandNotFound, "[#{logger_tag}] #{command_name} does not exist in the registry" if command.nil?

  command
end