Class: Vertx::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb

Overview

The parser transforms a CLI (a model) into an CommandLine. This CommandLine has stored the argument and option values. Only instance of parser should create objects of this type.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


20
21
22
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 20

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

+ (::Vertx::CommandLine) create(cli = nil)

Creates a command line object from the Vertx::CLI. This object is intended to be used by the parser to set the argument and option values.

Parameters:

  • cli (::Vertx::CLI) (defaults to: nil)
    the CLI definition

Returns:

Raises:

  • (ArgumentError)


39
40
41
42
43
44
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 39

def self.create(cli=nil)
  if cli.class.method_defined?(:j_del) && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreCli::CommandLine.java_method(:create, [Java::IoVertxCoreCli::CLI.java_class]).call(cli.j_del),::Vertx::CommandLine)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{cli})"
end

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

def self.j_class
  Java::IoVertxCoreCli::CommandLine.java_class
end

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

def @@j_api_type.wrap(obj)
  CommandLine.new(obj)
end

Instance Method Details

- (true, false) accept_more_values?(option = nil)

Checks whether or not the given option accept more values.

Parameters:

  • option (Hash) (defaults to: nil)
    the option

Returns:

  • (true, false)
    if the option accepts more values, otherwise.

Raises:

  • (ArgumentError)


141
142
143
144
145
146
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 141

def accept_more_values?(option=nil)
  if option.class == Hash && !block_given?
    return @j_del.java_method(:acceptMoreValues, [Java::IoVertxCoreCli::Option.java_class]).call(Java::IoVertxCoreCli::Option.new(::Vertx::Util::Utils.to_json_object(option)))
  end
  raise ArgumentError, "Invalid arguments when calling accept_more_values?(#{option})"
end

- (Array<String>) all_arguments

Returns the ordered list of arguments. Arguments are command line arguments not matching an option.

Returns:

  • (Array<String>)
    the ordered list of arguments. Arguments are command line arguments not matching an option.

Raises:

  • (ArgumentError)


53
54
55
56
57
58
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 53

def all_arguments
  if !block_given?
    return @j_del.java_method(:allArguments, []).call().to_a.map { |elt| elt }
  end
  raise ArgumentError, "Invalid arguments when calling all_arguments()"
end

- (true, false) argument_assigned?(arg = nil)

Checks whether or not the given argument has been assigned in the command line.

Parameters:

  • arg (Hash) (defaults to: nil)
    the argument

Returns:

  • (true, false)
    true if the argument has received a value, otherwise.

Raises:

  • (ArgumentError)


159
160
161
162
163
164
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 159

def argument_assigned?(arg=nil)
  if arg.class == Hash && !block_given?
    return @j_del.java_method(:isArgumentAssigned, [Java::IoVertxCoreCli::Argument.java_class]).call(Java::IoVertxCoreCli::Argument.new(::Vertx::Util::Utils.to_json_object(arg)))
  end
  raise ArgumentError, "Invalid arguments when calling argument_assigned?(#{arg})"
end

- (true, false) asking_for_help?

Checks whether or not the user has passed a "help" option and is asking for help.

Returns:

  • (true, false)
    true if the user command line has enabled a "Help" option, otherwise.

Raises:

  • (ArgumentError)


185
186
187
188
189
190
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 185

def asking_for_help?
  if !block_given?
    return @j_del.java_method(:isAskingForHelp, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling asking_for_help?()"
end

- (::Vertx::CLI) cli

Returns the model of this command line object.

Returns:

Raises:

  • (ArgumentError)


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

def cli
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:cli, []).call(),::Vertx::CLI)
  end
  raise ArgumentError, "Invalid arguments when calling cli()"
end

- (true, false) flag_enabled?(name = nil)

Gets the value of an option marked as a flag.

Calling this method an a non-flag option throws an IllegalStateException.

Parameters:

  • name (String) (defaults to: nil)
    the option name

Returns:

  • (true, false)
    true if the flag has been set in the command line, false otherwise.

Raises:

  • (ArgumentError)


87
88
89
90
91
92
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 87

def flag_enabled?(name=nil)
  if name.class == String && !block_given?
    return @j_del.java_method(:isFlagEnabled, [Java::java.lang.String.java_class]).call(name)
  end
  raise ArgumentError, "Invalid arguments when calling flag_enabled?(#{name})"
end

- (Object) getArgumentValue(name) - (Object) getArgumentValue(index)

Gets the value of an argument with the given index.

Overloads:

  • - (Object) getArgumentValue(name)

    Parameters:

    • name (String)
      the name
  • - (Object) getArgumentValue(index)

    Parameters:

    • index (Fixnum)
      the index

Returns:

  • (Object)
    the value, null if not set

Raises:

  • (ArgumentError)


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

def get_argument_value(param_1=nil)
  if param_1.class == String && !block_given?
    return ::Vertx::Util::Utils.from_object(@j_del.java_method(:getArgumentValue, [Java::java.lang.String.java_class]).call(param_1))
  elsif param_1.class == Fixnum && !block_given?
    return ::Vertx::Util::Utils.from_object(@j_del.java_method(:getArgumentValue, [Java::int.java_class]).call(param_1))
  end
  raise ArgumentError, "Invalid arguments when calling get_argument_value(#{param_1})"
end

- (Object) get_option_value(name = nil)

Gets the value of an option with the matching name (can be the long name, short name or arg name).

Parameters:

  • name (String) (defaults to: nil)
    the name

Returns:

  • (Object)
    the value, null if not set

Raises:

  • (ArgumentError)


62
63
64
65
66
67
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 62

def get_option_value(name=nil)
  if name.class == String && !block_given?
    return ::Vertx::Util::Utils.from_object(@j_del.java_method(:getOptionValue, [Java::java.lang.String.java_class]).call(name))
  end
  raise ArgumentError, "Invalid arguments when calling get_option_value(#{name})"
end

- (String) get_raw_value_for_argument(arg = nil)

Gets the raw value of the given argument. Raw values are the values as given in the user command line.

Parameters:

  • arg (Hash) (defaults to: nil)
    the argument

Returns:

  • (String)
    the value, null if none.

Raises:

  • (ArgumentError)


150
151
152
153
154
155
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 150

def get_raw_value_for_argument(arg=nil)
  if arg.class == Hash && !block_given?
    return @j_del.java_method(:getRawValueForArgument, [Java::IoVertxCoreCli::Argument.java_class]).call(Java::IoVertxCoreCli::Argument.new(::Vertx::Util::Utils.to_json_object(arg)))
  end
  raise ArgumentError, "Invalid arguments when calling get_raw_value_for_argument(#{arg})"
end

- (String) get_raw_value_for_option(option = nil)

Gets the raw value of the given option. Raw values are the values as given in the user command line.

Parameters:

  • option (Hash) (defaults to: nil)
    the option

Returns:

  • (String)
    the value, null if none.

Raises:

  • (ArgumentError)


132
133
134
135
136
137
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 132

def get_raw_value_for_option(option=nil)
  if option.class == Hash && !block_given?
    return @j_del.java_method(:getRawValueForOption, [Java::IoVertxCoreCli::Option.java_class]).call(Java::IoVertxCoreCli::Option.new(::Vertx::Util::Utils.to_json_object(option)))
  end
  raise ArgumentError, "Invalid arguments when calling get_raw_value_for_option(#{option})"
end

- (Array<String>) get_raw_values(option = nil)

Gets the raw values of the given option. Raw values are simple "String", not converted to the option type.

Parameters:

  • option (Hash) (defaults to: nil)
    the option

Returns:

  • (Array<String>)
    the list of values, empty if none

Raises:

  • (ArgumentError)


105
106
107
108
109
110
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 105

def get_raw_values(option=nil)
  if option.class == Hash && !block_given?
    return @j_del.java_method(:getRawValues, [Java::IoVertxCoreCli::Option.java_class]).call(Java::IoVertxCoreCli::Option.new(::Vertx::Util::Utils.to_json_object(option))).to_a.map { |elt| elt }
  end
  raise ArgumentError, "Invalid arguments when calling get_raw_values(#{option})"
end

- (Array<String>) get_raw_values_for_argument(argument = nil)

Gets the raw values of the given argument. Raw values are simple "String", not converted to the argument type.

Parameters:

  • argument (Hash) (defaults to: nil)
    the argument

Returns:

  • (Array<String>)
    the list of values, empty if none

Raises:

  • (ArgumentError)


123
124
125
126
127
128
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 123

def get_raw_values_for_argument(argument=nil)
  if argument.class == Hash && !block_given?
    return @j_del.java_method(:getRawValuesForArgument, [Java::IoVertxCoreCli::Argument.java_class]).call(Java::IoVertxCoreCli::Argument.new(::Vertx::Util::Utils.to_json_object(argument))).to_a.map { |elt| elt }
  end
  raise ArgumentError, "Invalid arguments when calling get_raw_values_for_argument(#{argument})"
end

- (Array<String>) get_raw_values_for_option(option = nil)

Gets the raw values of the given option. Raw values are simple "String", not converted to the option type.

Parameters:

  • option (Hash) (defaults to: nil)
    the option

Returns:

  • (Array<String>)
    the list of values, empty if none

Raises:

  • (ArgumentError)


114
115
116
117
118
119
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 114

def get_raw_values_for_option(option=nil)
  if option.class == Hash && !block_given?
    return @j_del.java_method(:getRawValuesForOption, [Java::IoVertxCoreCli::Option.java_class]).call(Java::IoVertxCoreCli::Option.new(::Vertx::Util::Utils.to_json_object(option))).to_a.map { |elt| elt }
  end
  raise ArgumentError, "Invalid arguments when calling get_raw_values_for_option(#{option})"
end

- (true, false) option_assigned?(option = nil)

Checks whether or not the given option has been assigned in the command line.

Parameters:

  • option (Hash) (defaults to: nil)
    the option

Returns:

  • (true, false)
    true if the option has received a value, otherwise.

Raises:

  • (ArgumentError)


96
97
98
99
100
101
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 96

def option_assigned?(option=nil)
  if option.class == Hash && !block_given?
    return @j_del.java_method(:isOptionAssigned, [Java::IoVertxCoreCli::Option.java_class]).call(Java::IoVertxCoreCli::Option.new(::Vertx::Util::Utils.to_json_object(option)))
  end
  raise ArgumentError, "Invalid arguments when calling option_assigned?(#{option})"
end

- (true, false) seen_in_command_line?(option = nil)

Checks whether or not the given option has been seen in the user command line.

Parameters:

  • option (Hash) (defaults to: nil)
    the option

Returns:

  • (true, false)
    true if the user command line has used the option

Raises:

  • (ArgumentError)


168
169
170
171
172
173
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 168

def seen_in_command_line?(option=nil)
  if option.class == Hash && !block_given?
    return @j_del.java_method(:isSeenInCommandLine, [Java::IoVertxCoreCli::Option.java_class]).call(Java::IoVertxCoreCli::Option.new(::Vertx::Util::Utils.to_json_object(option)))
  end
  raise ArgumentError, "Invalid arguments when calling seen_in_command_line?(#{option})"
end

- (true, false) valid?

Checks whether or not the command line is valid, i.e. all constraints from arguments and options have been satisfied. This method is used when the parser validation is disabled.

Returns:

Raises:

  • (ArgumentError)


177
178
179
180
181
182
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 177

def valid?
  if !block_given?
    return @j_del.java_method(:isValid, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling valid?()"
end