(c *cli.Context)
| 14 | type cmdEchoHandler struct{ dialer } |
| 15 | |
| 16 | func (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 | } |
nothing calls this directly
no test coverage detected