Class List Method List File List

# Class: VertxShell::CommandBuilder

Inherits:
  Object
  - Object
  - VertxShell::CommandBuilder
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-shell/src/main/resources/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
  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`)

    27
    28
    29
    30
    31
    32
    33
    34
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-shell/src/main/resources/vertx-shell/command_builder.rb', line 27

    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

Build the command

Returns:

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

Raises:

- (`ArgumentError`)

    58
    59
    60
    61
    62
    63
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-shell/src/main/resources/vertx-shell/command_builder.rb', line 58

    def build
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:build, []).call(),::VertxShell::Command)
      end
      raise ArgumentError, "Invalid arguments when calling build()"
    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`)

    49
    50
    51
    52
    53
    54
    55
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-shell/src/main/resources/vertx-shell/command_builder.rb', line 49

    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`)

    38
    39
    40
    41
    42
    43
    44
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-shell/src/main/resources/vertx-shell/command_builder.rb', line 38

    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