From 7fcb9dfa87310e91b527829ece9989decb6fda64 Mon Sep 17 00:00:00 2001 From: bndw Date: Sun, 28 Dec 2025 10:56:03 -0800 Subject: fixed logs -f --- internal/ssh/client.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'internal/ssh') diff --git a/internal/ssh/client.go b/internal/ssh/client.go index 1cd336c..b9c8d0f 100644 --- a/internal/ssh/client.go +++ b/internal/ssh/client.go @@ -132,6 +132,42 @@ func (c *Client) RunSudo(cmd string) (string, error) { return c.Run("sudo " + cmd) } +// RunSudoStream executes a command with sudo and streams output to stdout/stderr +func (c *Client) RunSudoStream(cmd string) error { + session, err := c.client.NewSession() + if err != nil { + return err + } + defer session.Close() + + session.Stdout = os.Stdout + session.Stderr = os.Stderr + + if err := session.Run("sudo " + cmd); err != nil { + return fmt.Errorf("command failed: %w", err) + } + + return nil +} + +// RunStream executes a command and streams output to stdout/stderr +func (c *Client) RunStream(cmd string) error { + session, err := c.client.NewSession() + if err != nil { + return err + } + defer session.Close() + + session.Stdout = os.Stdout + session.Stderr = os.Stderr + + if err := session.Run(cmd); err != nil { + return fmt.Errorf("command failed: %w", err) + } + + return nil +} + // Upload copies a local file to the remote host using scp func (c *Client) Upload(localPath, remotePath string) error { // Use external scp command for simplicity -- cgit v1.2.3