aboutsummaryrefslogtreecommitdiffstats
path: root/run_nonhost.go
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2024-10-18 14:07:53 -0500
committerMatt Strapp <matt@mattstrapp.net>2024-10-18 14:08:24 -0500
commite2e4f70f6b14d46d7dbbd2e0d5e7c3c3c69b47cc (patch)
treeeff37b3aa48182cde75e996d9ecfe2db7b1b2932 /run_nonhost.go
downloadwsl-tui-e2e4f70f6b14d46d7dbbd2e0d5e7c3c3c69b47cc.tar
wsl-tui-e2e4f70f6b14d46d7dbbd2e0d5e7c3c3c69b47cc.tar.gz
wsl-tui-e2e4f70f6b14d46d7dbbd2e0d5e7c3c3c69b47cc.tar.bz2
wsl-tui-e2e4f70f6b14d46d7dbbd2e0d5e7c3c3c69b47cc.tar.lz
wsl-tui-e2e4f70f6b14d46d7dbbd2e0d5e7c3c3c69b47cc.tar.xz
wsl-tui-e2e4f70f6b14d46d7dbbd2e0d5e7c3c3c69b47cc.tar.zst
wsl-tui-e2e4f70f6b14d46d7dbbd2e0d5e7c3c3c69b47cc.zip
Initial commit
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to '')
-rw-r--r--run_nonhost.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/run_nonhost.go b/run_nonhost.go
new file mode 100644
index 0000000..9742774
--- /dev/null
+++ b/run_nonhost.go
@@ -0,0 +1,18 @@
+//go:build !windows || nonhost
+
+package main
+
+import (
+ "errors"
+ "fmt"
+ "os/exec"
+ "strconv"
+)
+
+func command(distribution Distribution, config Config) (*exec.Cmd, error) {
+ if distribution.Username == "" || distribution.Port == 0 {
+ return nil, errors.New("SSH username or port not set, not running.")
+ }
+ args := append([]string{fmt.Sprintf("%s@%s", distribution.Username, config.HostIP), "-p", strconv.Itoa(distribution.Port)}, config.SshArgs...)
+ return exec.Command("ssh", args...), nil
+}