Class: Fuelcell::Parser::OptValueEqualHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/fuelcell/parser/opt_value_equal_handler.rb

Instance Method Summary collapse

Methods inherited from BaseHandler

#arg?, #assign_opt_value, #cast, #cast_array, #cast_bool, #cast_hash, #cast_numeric, #find_opt, #found_opt_flag, #take_first_arg

Instance Method Details

#call(cmd, args, opts) ⇒ Boolean

Handle options both long and short that express their value using an equal sign like –foo=bar or -f=bar

Parameters:

  • cmd (Fuelcell::Command)
  • args (Array)

    raw args from ARGV

  • opts (Hash)

    stores the found opts

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fuelcell/parser/opt_value_equal_handler.rb', line 12

def call(cmd, args, opts)
  return false unless take_first_arg(args) do |arg|
    !!(arg =~ /^(--\w+(?:-\w+)*|-[a-zA-Z])=(.*)$/)
  end

  name  = $1
  value = $2

  opt = find_opt(cmd, name)
  assign_opt_value(opts, opt, value, name)
  true
end