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-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb

## Overview

A build for Vert.x Shell command.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxShell::CommandBuilder) command(param_1 = nil)
  Create a new commmand with its Vertx::CLI descriptor.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## 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

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    22
    23
    24
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb', line 22

    def @@j_api_type.accept?(obj)
      obj.class == CommandBuilder
    end

### + (`::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`)

    44
    45
    46
    47
    48
    49
    50
    51
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb', line 44

    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

### + (`Object`) j_api_type

    31
    32
    33
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb', line 31

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

    34
    35
    36
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb', line 34

    def self.j_class
      Java::IoVertxExtShellCommand::CommandBuilder.java_class
    end

### + (`Object`) unwrap(obj)

    28
    29
    30
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb', line 28

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

    25
    26
    27
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb', line 25

    def @@j_api_type.wrap(obj)
      CommandBuilder.new(obj)
    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`)

    76
    77
    78
    79
    80
    81
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb', line 76

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

    66
    67
    68
    69
    70
    71
    72
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb', line 66

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

    55
    56
    57
    58
    59
    60
    61
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-shell/command_builder.rb', line 55

    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