Class: Toys::StandardMiddleware::HandleUsageErrors
- Inherits:
-
Object
- Object
- Toys::StandardMiddleware::HandleUsageErrors
- Defined in:
- lib/toys/standard_middleware/handle_usage_errors.rb
Overview
This middleware handles the case of a usage error. If a usage error, such as an unrecognized flag or an unfulfilled required argument, is detected, this middleware intercepts execution and displays the error along with the short help string, and terminates execution with an error code.
Constant Summary collapse
- USAGE_ERROR_EXIT_CODE =
Exit code for usage error. (2 by convention)
2
Instance Method Summary collapse
-
#initialize(exit_code: nil, stream: $stderr, styled_output: nil) ⇒ HandleUsageErrors
constructor
Create a HandleUsageErrors middleware.
Constructor Details
#initialize(exit_code: nil, stream: $stderr, styled_output: nil) ⇒ HandleUsageErrors
Create a HandleUsageErrors middleware.
28 29 30 31 32 |
# File 'lib/toys/standard_middleware/handle_usage_errors.rb', line 28 def initialize(exit_code: nil, stream: $stderr, styled_output: nil) @exit_code = exit_code || USAGE_ERROR_EXIT_CODE @stream = stream @styled_output = styled_output end |