Class: Clamp::Option::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/patches/clamp.rb

Instance Method Summary collapse

Instance Method Details

#extract_value(switch, arguments) ⇒ Object

Allow boolean flags to optionally receive a true/false argument to explicitly set them, i.e. –long.flag.name => sets flag to true –long.flag.name true => sets flag to true –long.flag.name false => sets flag to false –long.flag.name=true => sets flag to true –long.flag.name=false => sets flag to false



71
72
73
74
75
76
77
# File 'lib/logstash/patches/clamp.rb', line 71

def extract_value(switch, arguments)
  if flag? && (arguments.first.nil? || arguments.first.match("^-"))
    flag_value(switch)
  else
    arguments.shift
  end
end