Class: Vertx::CommandLine
- Inherits:
-
Object
- Object
- Vertx::CommandLine
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/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.
Class Method Summary (collapse)
-
+ (::Vertx::CommandLine) create(cli = nil)
Creates a command line object from the CLI.
Instance Method Summary (collapse)
-
- (true, false) accept_more_values?(option = nil)
Checks whether or not the given option accept more values.
-
- (Array<String>) all_arguments
@return the ordered list of arguments.
-
- (true, false) argument_assigned?(arg = nil)
Checks whether or not the given argument has been assigned in the command line.
-
- (::Vertx::CLI) cli
@return the model of this command line object.
-
- (true, false) flag_enabled?(name = nil)
Gets the value of an option marked as a flag.
-
- (Object) get_argument_value(param_1 = nil)
Gets the value of an argument with the given index.
-
- (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).
-
- (String) get_raw_value_for_argument(arg = nil)
Gets the raw value of the given argument.
-
- (String) get_raw_value_for_option(option = nil)
Gets the raw value of the given option.
-
- (Array<String>) get_raw_values(option = nil)
Gets the raw values of the given option.
-
- (true, false) option_assigned?(option = nil)
Checks whether or not the given option has been assigned in the command line.
-
- (true, false) seen_in_command_line?(option = nil)
check whether or not the given option has been seen in the user command line.
Class Method Details
+ (::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.
23 24 25 26 27 28 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 23 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 |
Instance Method Details
- (true, false) accept_more_values?(option = nil)
Checks whether or not the given option accept more values.
109 110 111 112 113 114 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 109 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
@return the ordered list of arguments. Arguments are command line arguments not matching an option.
39 40 41 42 43 44 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 39 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.
127 128 129 130 131 132 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 127 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 |
- (::Vertx::CLI) cli
@return the model of this command line object.
31 32 33 34 35 36 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 31 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.
73 74 75 76 77 78 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 73 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.
60 61 62 63 64 65 66 67 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 60 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).
48 49 50 51 52 53 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 48 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.
118 119 120 121 122 123 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 118 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.
100 101 102 103 104 105 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 100 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.
91 92 93 94 95 96 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 91 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 |
- (true, false) option_assigned?(option = nil)
Checks whether or not the given option has been assigned in the command line.
82 83 84 85 86 87 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 82 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)
check whether or not the given option has been seen in the user command line.
136 137 138 139 140 141 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/src/main/resources/vertx/command_line.rb', line 136 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 |