class
Squarectl::Executor
- Squarectl::Executor
- Reference
- Object
Overview
The single point where child processes are spawned.
Everything squarectl does eventually funnels through here, which is what
makes the rest of the code testable: specs inject an Executor whose output
is an IO::Memory to capture commands instead of running them. Three modes:
#run_command (spawn and wait for success), #exec_command (replace the
current process — never returns) and #capture_output (collect stdout).
:nodoc:
Defined in:
squarectl/executor.crConstructors
Instance Method Summary
- #capture_output(cmd : String, args : Array(String), env : Hash(String, String))
-
#capture_output(cmd : String, args : Array(String))
Runs the command and returns its trimmed stdout, or
nilif it failed or produced no output. -
#exec_command(cmd : String, args : Array(String), env : Hash(String, String)) : NoReturn
Replaces the current process with the command; used for interactive commands (e.g.
- #exec_command(cmd : String, args : Array(String))
-
#run_command(cmd : String, args : Array(String), env : Hash(String, String), input : File)
Variant that streams a file to the command's stdin (used to pipe config and secret contents into
docker config/secret create). -
#run_command(cmd : String, args : Array(String), env : Hash(String, String))
Spawns the command, waits for it, and raises
CommandErrorif it exits non-zero so the failure is not silently swallowed. - #run_command(cmd : String, args : Array(String))
Constructor Detail
Instance Method Detail
Runs the command and returns its trimmed stdout, or nil if it failed or
produced no output. Returning nil (rather than "") on empty output lets
callers distinguish "nothing found" from a real value (see the container-id
lookups in Commands::Swarm/Commands::Kubectl).
Replaces the current process with the command; used for interactive
commands (e.g. compose up, exec) so signals and the TTY pass through.
Variant that streams a file to the command's stdin (used to pipe config and
secret contents into docker config/secret create).
Spawns the command, waits for it, and raises CommandError if it exits
non-zero so the failure is not silently swallowed.