Class List Method List File List

# Class: VertxShell::CommandBuilder

Inherits:
  Object
  - Object
  - VertxShell::CommandBuilder
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_builder.rb

## Overview

A build for Vert.x Shell command.

## Class Method Summary (collapse)

- + (::VertxShell::CommandBuilder) command(param_1 = nil)
  Create a new commmand with its Vertx::CLI descriptor.

## Instance Method Summary (collapse)

- - (::VertxShell::Command) build(vertx = nil)
  Build the command.
- - (self) completion_handler { ... }
  Set the command completion handler, the completion handler when the user asks for contextual command line completion, usually hitting the tab key.
- - (self) process_handler { ... }
  Set the command process handler, the process handler is called when the command is executed.

## Class Method Details

### + (`::VertxShell::CommandBuilder`) command(name) + (`::VertxShell::CommandBuilder`) command(cli)

Create a new commmand with its Vertx::CLI descriptor. This command can then retrieve the parsed VertxShell::CommandProcess#command_line when it executes to know get the command arguments and options.

Overloads:

- + (`::VertxShell::CommandBuilder`) command(name)

  Parameters:

  - name (`String`) —
    the command name
- + (`::VertxShell::CommandBuilder`) command(cli)

  Parameters:

  - cli (`::Vertx::CLI`) —
    the cli to use

Returns:

- (`::VertxShell::CommandBuilder`) —
  the command

Raises:

- (`ArgumentError`)

    28
    29
    30
    31
    32
    33
    34
    35
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_builder.rb', line 28

    def self.command(param_1=nil)
      if param_1.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtShellCommand::CommandBuilder.java_method(:command, [Java::java.lang.String.java_class]).call(param_1),::VertxShell::CommandBuilder)
      elsif param_1.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtShellCommand::CommandBuilder.java_method(:command, [Java::IoVertxCoreCli::CLI.java_class]).call(param_1.j_del),::VertxShell::CommandBuilder)
      end
      raise ArgumentError, "Invalid arguments when calling command(param_1)"
    end

## Instance Method Details

### - (`::VertxShell::Command`) build(vertx = nil)

Build the command

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the vertx instance

Returns:

- (`::VertxShell::Command`) —
  the built command

Raises:

- (`ArgumentError`)

    60
    61
    62
    63
    64
    65
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_builder.rb', line 60

    def build(vertx=nil)
      if vertx.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:build, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxShell::Command)
      end
      raise ArgumentError, "Invalid arguments when calling build(vertx)"
    end

### - (`self`) completion_handler { ... }

Set the command completion handler, the completion handler when the user asks for contextual command line completion, usually hitting the tab key.

Yields:

- the completion handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    50
    51
    52
    53
    54
    55
    56
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_builder.rb', line 50

    def completion_handler
      if block_given?
        @j_del.java_method(:completionHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxShell::Completion)) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling completion_handler()"
    end

### - (`self`) process_handler { ... }

Set the command process handler, the process handler is called when the command is executed.

Yields:

- the process handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    39
    40
    41
    42
    43
    44
    45
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-shell/command_builder.rb', line 39

    def process_handler
      if block_given?
        @j_del.java_method(:processHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxShell::CommandProcess)) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling process_handler()"
    end