Class: Aidp::ShellExecutor
- Inherits:
-
Object
- Object
- Aidp::ShellExecutor
- Defined in:
- lib/aidp/shell_executor.rb
Overview
Shell command executor wrapper for testability
Provides two modes of execution:
run(command)- Captures output silently via backtickssystem(*args)- Wraps Kernel.system() with optional output suppression
In tests, set ShellExecutor.suppress_output = true to suppress all
system() output without changing any production code behavior.
Class Attribute Summary collapse
-
.suppress_output ⇒ Object
When true, system() calls will have output redirected to /dev/null Default: false (output shown normally).
Instance Method Summary collapse
-
#run(command) ⇒ String
Run a command and capture its output.
-
#success? ⇒ Boolean
Check if the last command succeeded.
-
#system(*args, **opts) ⇒ Boolean?
Run a command via system(), optionally suppressing output.
Class Attribute Details
.suppress_output ⇒ Object
When true, system() calls will have output redirected to /dev/null Default: false (output shown normally)
24 25 26 |
# File 'lib/aidp/shell_executor.rb', line 24 def suppress_output @suppress_output end |
Instance Method Details
#run(command) ⇒ String
Run a command and capture its output
32 33 34 |
# File 'lib/aidp/shell_executor.rb', line 32 def run(command) `#{command}` end |
#success? ⇒ Boolean
Check if the last command succeeded
39 40 41 |
# File 'lib/aidp/shell_executor.rb', line 39 def success? $?.success? end |
#system(*args, **opts) ⇒ Boolean?
Run a command via system(), optionally suppressing output
When suppress_output is true, output is redirected to /dev/null unless explicit out:/err: options are provided.
51 52 53 54 55 56 |
# File 'lib/aidp/shell_executor.rb', line 51 def system(*args, **opts) if self.class.suppress_output && !opts.key?(:out) && !opts.key?(:err) opts = opts.merge(out: File::NULL, err: File::NULL) end Kernel.system(*args, **opts) end |