class Discharger::SetupRunner::Commands::BaseCommand
def system!(*args)
def system!(*args) require "open3" command_str = args.join(" ") # Create a more readable message for the spinner spinner_message = if command_str.length > 80 if args.first.is_a?(Hash) # Skip env hash in display cmd_args = args[1..] base_cmd = cmd_args.take(3).join(" ") else base_cmd = args.take(3).join(" ") end "Executing #{base_cmd}..." else "Executing #{command_str}" end result = with_spinner(spinner_message) do stdout, stderr, status = Open3.capture3(*args) if status.success? # Log output if there is any (for debugging) logger&.debug("Output: #{stdout}") if stdout && !stdout.empty? {success: true, message: "✓"} elsif args.first.to_s.include?("docker") logger&.debug("Error: #{stderr}") if stderr && !stderr.empty? {success: false, message: "✗ (Docker command failed)", raise_error: false} else {success: false, message: "✗", error: "#{command_str} failed: #{stderr}"} end end # Handle the case when spinner is disabled if result.is_a?(Hash) && !result[:success] && result[:raise_error] != false raise result[:error] end result end