Module: CLIClassTool
- Defined in:
- lib/cli_class_tool/common.rb,
lib/cli_class_tool.rb,
lib/cli_class_tool/utils.rb
Overview
Main module for generic CLI class-based tools and utilities
Defined Under Namespace
Modules: Utils Classes: Common, RunError
Class Method Summary collapse
Class Method Details
.define_run_error(parent_module, superclass = CLIClassTool::RunError) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cli_class_tool.rb', line 12 def self.define_run_error(parent_module, superclass = CLIClassTool::RunError) klass = Class.new(superclass) if !(superclass <= CLIClassTool::RunError) klass.class_eval do attr_reader :err_code, :output def initialize(err_code, output = nil) @err_code = err_code @output = output super("Command failed with exit status #{err_code}#{output ? "\n#{output}" : ''}") end end end parent_module.const_set(:RunError, klass) end |