MCPcopy
hub / github.com/DarthSim/overmind / Run

Method Run

cmd_echo.go:16–42  ·  view source on GitHub ↗
(c *cli.Context)

Source from the content-addressed store, hash-verified

14type cmdEchoHandler struct{ dialer }
15
16func (h *cmdEchoHandler) Run(c *cli.Context) error {
17 if c.Args().Present() {
18 utils.Fatal("Echo doesn't accept any arguments")
19 }
20
21 conn, err := h.Dial()
22 utils.FatalOnErr(err)
23
24 stop := make(chan os.Signal, 1)
25
26 go func() {
27 utils.ScanLines(conn, func(b []byte) bool {
28 fmt.Fprintf(os.Stdout, "%s\n", b)
29 return true
30 })
31
32 stop <- syscall.SIGINT
33 }()
34
35 fmt.Fprintln(conn, "echo")
36
37 signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM)
38
39 <-stop
40
41 return nil
42}

Callers

nothing calls this directly

Calls 4

FatalFunction · 0.92
FatalOnErrFunction · 0.92
ScanLinesFunction · 0.92
DialMethod · 0.80

Tested by

no test coverage detected