Method: CommandMapper::Option#argv
- Defined in:
- lib/command_mapper/option.rb
#argv(argv = [], value) ⇒ Array<String>
Converts the given value into the command-line arguments for the option's flag and value.
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/command_mapper/option.rb', line 184 def argv(argv=[],value) valid, = validate(value) unless valid raise(ValidationError,"option #{@name} was given an invalid value (#{value.inspect}): #{message}") end if accepts_value? if repeats? values = Array(value) values.each do |element| emit_option_flag_and_value(argv,element) end else emit_option_flag_and_value(argv,value) end else emit_option_flag_only(argv,value) end return argv end |