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"` }