From 9df33c1ca0aa3203d61ab6d2410576723f9f07c3 Mon Sep 17 00:00:00 2001 From: finn Date: Fri, 18 Mar 2022 20:04:43 -0700 Subject: [PATCH] committing so i can push so i can show off still not ready --- cmd/signaldctl/cmd/subscribe.go | 16 +++++++++++++--- signald/client-protocol/protocol.go | 8 ++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cmd/signaldctl/cmd/subscribe.go b/cmd/signaldctl/cmd/subscribe.go index c15c7ad..fba48a9 100644 --- a/cmd/signaldctl/cmd/subscribe.go +++ b/cmd/signaldctl/cmd/subscribe.go @@ -2,6 +2,7 @@ package cmd import ( "encoding/json" + "log" "os" "github.com/spf13/cobra" @@ -24,6 +25,10 @@ var ( if accountIdentifier == "" { accountIdentifier = config.Config.DefaultAccount } + if accountIdentifier == "" { + common.Must(cmd.Help()) + log.Fatal("No account specified. Please specify with --account or set a default") + } }, RunE: func(cmd *cobra.Command, args []string) error { incoming := make(chan client_protocol.BasicResponse) @@ -36,9 +41,14 @@ var ( } for msg := range incoming { - err := json.NewEncoder(os.Stdout).Encode(msg) - if err != nil { - panic(err) + switch common.OutputFormat { + case common.OutputFormatJSON, common.OutputFormatDefault: + err := json.NewEncoder(os.Stdout).Encode(msg) + if err != nil { + panic(err) + } + default: + log.Fatal("unsupported output format") } } return nil diff --git a/signald/client-protocol/protocol.go b/signald/client-protocol/protocol.go index f6f763f..c0cb562 100644 --- a/signald/client-protocol/protocol.go +++ b/signald/client-protocol/protocol.go @@ -5,10 +5,10 @@ import ( ) type BasicResponse struct { - ID string `json:"id,omitempty"` - Type string `json:"type,omitempty"` - ErrorType string `json:"error_type,omitempty"` + ID string `json:"id,omitempty"` + Type string `json:"type,omitempty"` + ErrorType string `json:"error_type,omitempty"` Error json.RawMessage `json:"error,omitempty"` Data json.RawMessage `json:"data,omitempty"` - Account string `json:"account,omitempty"` + Account string `json:"account,omitempty"` }