diff --git a/client.go b/client.go index 1caf279..4e4c249 100644 --- a/client.go +++ b/client.go @@ -146,7 +146,7 @@ func loadFiles() (list []string, copy bool, err error) { return } -func sendServer(cmd string) error { +func sendRemote(cmd string) error { c, err := net.Dial("unix", gSocketPath) if err != nil { return fmt.Errorf("dialing to send server: %s", err) diff --git a/eval.go b/eval.go index 9b29035..f4a7626 100644 --- a/eval.go +++ b/eval.go @@ -274,7 +274,7 @@ func (e *callExpr) eval(app *app, args []string) { return } app.nav.marks = make(map[string]bool) - if err := sendServer("send sync"); err != nil { + if err := sendRemote("send sync"); err != nil { msg := fmt.Sprintf("yank: %s", err) app.ui.message = msg log.Printf(msg) @@ -287,7 +287,7 @@ func (e *callExpr) eval(app *app, args []string) { return } app.nav.marks = make(map[string]bool) - if err := sendServer("send sync"); err != nil { + if err := sendRemote("send sync"); err != nil { msg := fmt.Sprintf("delete: %s", err) app.ui.message = msg log.Printf(msg) diff --git a/main.go b/main.go index 646bbb2..3a37a76 100644 --- a/main.go +++ b/main.go @@ -72,6 +72,7 @@ func startServer() { func main() { showDoc := flag.Bool("doc", false, "show documentation") + remoteCmd := flag.String("remote", "", "send remote command to server") serverMode := flag.Bool("server", false, "start server (automatic)") cpuprofile := flag.String("cpuprofile", "", "path to the file to write the cpu profile") flag.StringVar(&gLastDirPath, "last-dir-path", "", "path to the file to write the last dir on exit (to use for cd)") @@ -84,13 +85,20 @@ func main() { return } + if *remoteCmd != "" { + if err := sendRemote(*remoteCmd); err != nil { + log.Fatalf("remote command: %s", err) + } + return + } + if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { - log.Fatal("could not create CPU profile: ", err) + log.Fatalf("could not create CPU profile: %s", err) } if err := pprof.StartCPUProfile(f); err != nil { - log.Fatal("could not start CPU profile: ", err) + log.Fatalf("could not start CPU profile: %s", err) } defer pprof.StopCPUProfile() }