Method: PryCommandSetRegistry.define_command_set

Defined in:
lib/pry_command_set_registry.rb

.define_command_set(name, description, options = {}) { ... } ⇒ PryCommandSetRegistry::CommandSet

Helper method for defining a command set and registering it immediately. All arguments are passed directly to CommandSet#initialize to instantiate a new command set.

Examples:

Create a new CommandSet with a ‘hello-world` command

PryCommandSetRegistry.define_command_set("Examples", "Example Commands", :group => "Examples") do
  command("hello-world", "Greets the world") do
    _pry_.outputter.puts("Hello world!")
  end
end

Parameters:

  • name (String, Symbol)

    The name that should be given to the command set. The provided name will be displayed by the ‘list-sets` command and is used to identify the command set when calling the `import-set` command.

  • description (String)

    A description of the command set. The provided description will be displayed by the ‘list-sets` command.

  • options (Hash{Symbol=>String}) (defaults to: {})

    Optional arguments.

Options Hash (options):

  • group (String)

    A group name to apply to all commands in the command set. This group will be displayed in commands like ‘help`, however depending on the version of pry it may be sentence cased when displayed. When no group is provided, Pry will use `(other)` by default.

Yields:

  • The provided block is evaluated by the command set instance and is used to define commands and configure the command set in other ways.

Returns:

Raises:

  • (ArgumentError)

    if no block is given.

See Also:



59
# File 'lib/pry_command_set_registry.rb', line 59

def_delegators :registry, :command_set, :command_sets, :define_command_set