-// Helper copied to the remote hosts to run commands and deploy configuration
+// Helper copied to the remote host to run commands and deploy configuration
// Copyright (C) 2021 Simon Ruderich
//
"log"
"os"
+ "golang.org/x/term"
+
"ruderich.org/simon/safcm"
"ruderich.org/simon/safcm/cmd/safcm-remote/ainsl"
"ruderich.org/simon/safcm/cmd/safcm-remote/info"
}
func mainLoop() error {
+ if term.IsTerminal(int(os.Stdin.Fd())) ||
+ term.IsTerminal(int(os.Stdout.Fd())) {
+ return fmt.Errorf("sync should only be called from `safcm` " +
+ "(redirect stdin/stdout to circumvent this check)")
+ }
+
conn := safcm.NewGobConn(os.Stdin, os.Stdout)
var logLevel safcm.LogLevel
- logFunc := func(level safcm.LogLevel, format string, a ...interface{}) {
+ logFunc := func(level safcm.LogLevel, msg string) {
if logLevel >= level {
conn.Send(safcm.MsgLog{
Level: level,
- Text: fmt.Sprintf(format, a...),
+ Text: msg,
})
}
}