Class: Thor::Options
- Inherits:
-
Arguments
- Object
- Arguments
- Thor::Options
- Defined in:
- lib/pact_broker/client/cli/thor_unknown_options_monkey_patch.rb
Instance Method Summary collapse
-
#check_unknown! ⇒ Object
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.
- #check_unknown_and_warn ⇒ Object
- #original_check_unknown! ⇒ Object
- #raise_error_on_unknown_options? ⇒ Boolean
Instance Method Details
#check_unknown! ⇒ Object
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.
16 17 18 19 20 21 22 |
# File 'lib/pact_broker/client/cli/thor_unknown_options_monkey_patch.rb', line 16 def check_unknown! if original_check_unknown! else check_unknown_and_warn end end |
#check_unknown_and_warn ⇒ Object
28 29 30 31 32 33 34 35 36 |
# 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.)) $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! ⇒ Object
11 |
# File 'lib/pact_broker/client/cli/thor_unknown_options_monkey_patch.rb', line 11 alias_method :original_check_unknown!, :check_unknown! |
#raise_error_on_unknown_options? ⇒ Boolean
24 25 26 |
# File 'lib/pact_broker/client/cli/thor_unknown_options_monkey_patch.rb', line 24 def ENV["PACT_BROKER_ERROR_ON_UNKNOWN_OPTION"] == "true" end |