summaryrefslogtreecommitdiffstats
path: root/cmd/goctl
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2015-07-02 12:46:18 -0400
committerBrian Cully <bjc@kublai.com>2015-07-02 12:46:18 -0400
commitf9280d74087ddbd9cfad154101fde2a8bd67b186 (patch)
tree63061b6c725e9493cd9a6a12f853b443e285128c /cmd/goctl
downloadgoctl-f9280d74087ddbd9cfad154101fde2a8bd67b186.tar.gz
goctl-f9280d74087ddbd9cfad154101fde2a8bd67b186.zip
Initial commit.
Diffstat (limited to 'cmd/goctl')
-rw-r--r--cmd/goctl/main.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/cmd/goctl/main.go b/cmd/goctl/main.go
new file mode 100644
index 0000000..1537c9a
--- /dev/null
+++ b/cmd/goctl/main.go
@@ -0,0 +1,35 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "net"
+ "os"
+ "strings"
+
+ "github.com/bjc/goctl"
+)
+
+func main() {
+ var path = flag.String("path", "", "Socket path for sending commands (required).")
+ flag.Parse()
+
+ if *path == "" {
+ flag.Usage()
+ os.Exit(1)
+ }
+
+ c, err := net.Dial("unix", *path)
+ if err != nil {
+ log.Fatalf("Couldn't connect to %s: %s.", *path, err)
+ }
+ defer c.Close()
+
+ goctl.Write(c, []byte(strings.Join(flag.Args(), " ")))
+ if buf, err := goctl.Read(c); err != nil {
+ log.Fatalf("Error reading response from command: %s.", err)
+ } else {
+ fmt.Println(string(buf))
+ }
+}