Class: BaseScript
- Inherits:
-
Object
- Object
- BaseScript
- Defined in:
- lib/base_script.rb,
lib/base_script/version.rb more...
Overview
A base class for implementing CLI scripts. ARGV and in/out IO’s are injected, so can be mocked & tested. Basic signal handling by calling exit_on_signals inside work loops etc. Requires Ruby 2.0.0+ for keyword args etc.
Constant Summary collapse
- EXIT_SUCCESS =
0
- INDENT =
" "
- VERSION =
"1.3.0"
Instance Method Summary collapse
-
#initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr) ⇒ BaseScript
constructor
A new instance of BaseScript.
Constructor Details
permalink #initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr) ⇒ BaseScript
Returns a new instance of BaseScript.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/base_script.rb', line 13 def initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr) @argv = argv @input = stdin @output = stdout @error_output = stderr sync_io! @indentation = 0 end |