diff --git a/cmd/signald-cli/cmd/send.go b/cmd/signald-cli/cmd/send.go index dbba3d7..a6132bd 100644 --- a/cmd/signald-cli/cmd/send.go +++ b/cmd/signald-cli/cmd/send.go @@ -19,6 +19,7 @@ import ( "log" "github.com/spf13/cobra" + "time" "git.callpipe.com/finn/signald-go/signald" "git.callpipe.com/finn/signald-go/signald/client-protocol/v1" @@ -59,6 +60,20 @@ var sendCmd = &cobra.Command{ request.AttachmentFilenames = []string{attachment} } s.SendRequest(request) + + timeout := 10 + + // Wait for the response + c := make(chan signald.Response) + + go s.Listen(c) + select { + case <-c: + log.Println("Ok.") + case <-time.After(1 * time.Second): + // But timeout after a while + log.Fatalf("Timeout after %d seconds\n", timeout) + } }, }