warren/cmd/warren/cmd_run.go

47 lines
778 B
Go

package main
import (
"fmt"
"github.com/dballard/warren/lib/warren"
"log"
"net"
"strings"
// "os"
// "os/exec"
// "time"
)
var runUsage = `
warren run - Interfaces with warrend to manage running instances
`
var runCmd = &Command{
Name: "run",
Usage: "",
Summary: "Interface to warrend to manage running instances",
Help: runUsage,
Run: runRun,
}
func runRun(cmd *Command, args ...string) {
if len(args) == 0 || args[0] == "help" {
fmt.Print(cmd.Help)
return
}
s, err := net.Dial(warren.CmdSockType(), warren.CmdSockAddr())
if err != nil {
log.Fatal("Error connecting to warrend:", err)
}
s.Write([]byte(strings.Join(args, " ") + "\000"))
resp, err := warren.ReadStringz(s)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp)
}