class Thor::Options

Public Instance Methods

check_unknown!() click to toggle source

Replace the original check_unknown! method with an implementation that will print a warning rather than raising an error unless PACT_BROKER_ERROR_ON_UNKNOWN_OPTION=true is set.

# File lib/pact_broker/client/cli/thor_unknown_options_monkey_patch.rb, line 16
def check_unknown!
  if raise_error_on_unknown_options?
    original_check_unknown!
  else
    check_unknown_and_warn
  end
end
Also aliased as: original_check_unknown!
check_unknown_and_warn() click to toggle source
# File lib/pact_broker/client/cli/thor_unknown_options_monkey_patch.rb, line 28
def check_unknown_and_warn
  begin
    original_check_unknown!
  rescue UnknownArgumentError => e
    $stderr.puts(::Term::ANSIColor.yellow(e.message))
    $stderr.puts(::Term::ANSIColor.yellow("This is a warning rather than an error so as not to break backwards compatibility. To raise an error for unknown options set PACT_BROKER_ERROR_ON_UNKNOWN_OPTION=true"))
    $stderr.puts("\n")
  end
end
original_check_unknown!()
Alias for: check_unknown!
raise_error_on_unknown_options?() click to toggle source
# File lib/pact_broker/client/cli/thor_unknown_options_monkey_patch.rb, line 24
def raise_error_on_unknown_options?
  ENV["PACT_BROKER_ERROR_ON_UNKNOWN_OPTION"] == "true"
end