package infra

import (
	"fmt"
	"os/exec"
	"strings"
)

// SSHUpload sube un archivo local al host remoto via scp.
func SSHUpload(conn SSHConn, localPath, remotePath string) error {
	args := conn.scpArgs()
	dest := fmt.Sprintf("%s:%s", conn.destination(), remotePath)
	args = append(args, localPath, dest)

	out, err := exec.Command("scp", args...).CombinedOutput()
	if err != nil {
		return fmt.Errorf("scp upload to %s: %s", conn.destination(), strings.TrimSpace(string(out)))
	}
	return nil
}
