Class: Cuprum::Cli::Integrations::Thor::Registry

Inherits:
Registry
  • Object
show all
Defined in:
lib/cuprum/cli/integrations/thor/registry.rb

Overview

Registers CLI commands by name and adds as Thor tasks.

Instance Method Summary collapse

Methods inherited from Registry

#[], #commands

Instance Method Details

#register(command, **config) ⇒ self Also known as: add

Registers the command with the registry.

Also registers a Thor task with compatible parameters and metadata.

Parameters:

  • command (Class)

    the command class to register.

  • config (Hash)

    options for configuring the command.

Options Hash (**config):

  • arguments (Array)

    arguments to pass to the command on initialization.

  • description (String)

    the description for the command.

  • full_description (String)

    the full description for the command.

  • full_name (String)

    the name under which to register the command. Defaults to the value of command.full_name.

  • options (Hash)

    options to pass to the command on initialization.

Returns:

  • (self)

Raises:

  • (NameError)

    if a command is already registered with that name.



30
31
32
33
34
35
36
37
38
39
# File 'lib/cuprum/cli/integrations/thor/registry.rb', line 30

def register(command, **config)
  super.tap do
    name    = config.fetch(:full_name, command.full_name)
    command = commands[name]

    Cuprum::Cli::Integrations::Thor::Task::Builder
      .new(command)
      .build(full_name: name)
  end
end