committing so i can push so i can show off

still not ready
This commit is contained in:
finn 2022-03-18 20:04:43 -07:00
parent 25501ecdf6
commit 9df33c1ca0
2 changed files with 17 additions and 7 deletions

View file

@ -2,6 +2,7 @@ package cmd
import ( import (
"encoding/json" "encoding/json"
"log"
"os" "os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -24,6 +25,10 @@ var (
if accountIdentifier == "" { if accountIdentifier == "" {
accountIdentifier = config.Config.DefaultAccount 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 { RunE: func(cmd *cobra.Command, args []string) error {
incoming := make(chan client_protocol.BasicResponse) incoming := make(chan client_protocol.BasicResponse)
@ -36,9 +41,14 @@ var (
} }
for msg := range incoming { for msg := range incoming {
err := json.NewEncoder(os.Stdout).Encode(msg) switch common.OutputFormat {
if err != nil { case common.OutputFormatJSON, common.OutputFormatDefault:
panic(err) err := json.NewEncoder(os.Stdout).Encode(msg)
if err != nil {
panic(err)
}
default:
log.Fatal("unsupported output format")
} }
} }
return nil return nil

View file

@ -5,10 +5,10 @@ import (
) )
type BasicResponse struct { type BasicResponse struct {
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"` Type string `json:"type,omitempty"`
ErrorType string `json:"error_type,omitempty"` ErrorType string `json:"error_type,omitempty"`
Error json.RawMessage `json:"error,omitempty"` Error json.RawMessage `json:"error,omitempty"`
Data json.RawMessage `json:"data,omitempty"` Data json.RawMessage `json:"data,omitempty"`
Account string `json:"account,omitempty"` Account string `json:"account,omitempty"`
} }