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



77
78
79
80
81
82
83
# File 'lib/logstash/patches/clamp.rb', line 77

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