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)


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

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

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

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:

Returns:



238
239
240
241
242
243
244
245
246
247
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 238

def self.create(*args)
  if args[0].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(args[0].j_del),::Vertx::CommandLine)
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling create(#{args[0]})"
  end
end

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

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

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (true, false) acceptMoreValues(option)

Checks whether or not the given option accept more values.

Parameters:

  • option (Hash{String => Object})
    the option

Returns:

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


98
99
100
101
102
103
104
105
106
107
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 98

def accept_more_values?(*args)
  if args[0].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(args[0])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling accept_more_values?(#{args[0]})"
  end
end

- (Array<String>) allArguments

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.


152
153
154
155
156
157
158
159
160
161
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 152

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

- (true, false) isArgumentAssigned(arg)

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

Parameters:

  • arg (Hash{String => Object})
    the argument

Returns:

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


126
127
128
129
130
131
132
133
134
135
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 126

def argument_assigned?(*args)
  if args[0].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(args[0])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling argument_assigned?(#{args[0]})"
  end
end

- (true, false) isAskingForHelp

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.


223
224
225
226
227
228
229
230
231
232
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 223

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

- (::Vertx::CLI) cli

Returns the model of this command line object.

Returns:



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

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

- (true, false) isFlagEnabled(name)

Gets the value of an option marked as a flag.

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

Parameters:

  • name (String)
    the option name

Returns:

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


196
197
198
199
200
201
202
203
204
205
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 196

def flag_enabled?(*args)
  if args[0].class == String && !block_given?
    return @j_del.java_method(:isFlagEnabled, [Java::java.lang.String.java_class]).call(args[0])
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling flag_enabled?(#{args[0]})"
  end
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


68
69
70
71
72
73
74
75
76
77
78
79
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 68

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

- (Object) getOptionValue(name)

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

Parameters:

  • name (String)
    the name

Returns:

  • (Object)
    the value, null if not set


210
211
212
213
214
215
216
217
218
219
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 210

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

- (String) getRawValueForArgument(arg)

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

Parameters:

  • arg (Hash{String => Object})
    the argument

Returns:

  • (String)
    the value, null if none.


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

def get_raw_value_for_argument(*args)
  if args[0].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(args[0])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_raw_value_for_argument(#{args[0]})"
  end
end

- (String) getRawValueForOption(option)

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

Parameters:

  • option (Hash{String => Object})
    the option

Returns:

  • (String)
    the value, null if none.


252
253
254
255
256
257
258
259
260
261
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 252

def get_raw_value_for_option(*args)
  if args[0].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(args[0])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_raw_value_for_option(#{args[0]})"
  end
end

- (Array<String>) getRawValues(option)

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

Parameters:

  • option (Hash{String => Object})
    the option

Returns:

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


266
267
268
269
270
271
272
273
274
275
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/command_line.rb', line 266

def get_raw_values(*args)
  if args[0].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(args[0]))).to_a.map { |elt| elt }
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_raw_values(#{args[0]})"
  end
end

- (Array<String>) getRawValuesForArgument(argument)

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

Parameters:

  • argument (Hash{String => Object})
    the argument

Returns:

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


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

def get_raw_values_for_argument(*args)
  if args[0].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(args[0]))).to_a.map { |elt| elt }
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_raw_values_for_argument(#{args[0]})"
  end
end

- (Array<String>) getRawValuesForOption(option)

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

Parameters:

  • option (Hash{String => Object})
    the option

Returns:

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


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

def get_raw_values_for_option(*args)
  if args[0].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(args[0]))).to_a.map { |elt| elt }
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling get_raw_values_for_option(#{args[0]})"
  end
end

- (true, false) isOptionAssigned(option)

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

Parameters:

  • option (Hash{String => Object})
    the option

Returns:

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


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

def option_assigned?(*args)
  if args[0].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(args[0])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling option_assigned?(#{args[0]})"
  end
end

- (true, false) isSeenInCommandLine(option)

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

Parameters:

  • option (Hash{String => Object})
    the option

Returns:

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


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

def seen_in_command_line?(*args)
  if args[0].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(args[0])))
  end
  if defined?(super)
    super
  else
    raise ArgumentError, "Invalid arguments when calling seen_in_command_line?(#{args[0]})"
  end
end

- (true, false) isValid

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:



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

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