Module: RakeCommander::Options::Error::Handling::ClassMethods
- Defined in:
- lib/rake-commander/options/error/handling.rb
Instance Attribute Summary collapse
-
#options_latest_error ⇒ Object
readonly
Returns the value of attribute options_latest_error.
Instance Method Summary collapse
- #error_on_leftovers(action = :not_used, &handler) ⇒ Object
-
#error_on_options(action = :not_used, error: RakeCommander::Options::Error::Base) {|error, argv, results, leftovers| ... } ⇒ Boolean
Whether it should trigger an error when there are
ARGVoption errors duringparse_options. -
#error_on_options?(error = RakeCommander::Options::Error::Base) ⇒ Boolean
Whether there is an error
actiondefined forerror.
Instance Attribute Details
#options_latest_error ⇒ Object (readonly)
Returns the value of attribute options_latest_error.
17 18 19 |
# File 'lib/rake-commander/options/error/handling.rb', line 17 def end |
Instance Method Details
#error_on_leftovers(action = :not_used, &handler) ⇒ Object
61 62 63 |
# File 'lib/rake-commander/options/error/handling.rb', line 61 def error_on_leftovers(action = :not_used, &handler) (action, error: RakeCommander::Options::Error::UnknownArgument, &handler) end |
#error_on_options(action = :not_used, error: RakeCommander::Options::Error::Base) {|error, argv, results, leftovers| ... } ⇒ Boolean
Note:
- It triggers error by default when there are parsing option errors.
- Even if a
handlerblock is defined, if action isfalseit won't trigger error. - When specific errors are NOT specified, they will fallback to the action defined
on the parent class
RakeCommander::Options::Error::Base. This means that you can define a default behaviour for this.
Whether it should trigger an error when there are ARGV option errors during parse_options
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rake-commander/options/error/handling.rb', line 42 def (action = :not_used, error: RakeCommander::Options::Error::Base, &handler) RakeCommander::Options::Error::Base.require_argument!(error, :error, accept_children: true) = nil ||= {} [error] = action if action != :not_used if block_given? (error, &handler) [error] ||= true end return self unless block_given? || action != :not_used # default value [error] = true unless [error] == false [error] end |
#error_on_options?(error = RakeCommander::Options::Error::Base) ⇒ Boolean
Returns whether there is an error action defined for error.
66 67 68 69 70 |
# File 'lib/rake-commander/options/error/handling.rb', line 66 def (error = RakeCommander::Options::Error::Base) RakeCommander::Options::Error::Base.require_argument!(error, :error, accept_children: true) _default_action = .key?(error) || .key?(error) end |