diff --git a/notecard/main.go b/notecard/main.go index e2c229b..f036b00 100644 --- a/notecard/main.go +++ b/notecard/main.go @@ -9,6 +9,7 @@ import ( "fmt" "os" "os/signal" + "strconv" "io/ioutil" "strings" "syscall" @@ -164,14 +165,8 @@ func main() { } notecard.InitialDebugMode = actionVerbose card, err = notecard.Open(lib.Config.Interface, lib.Config.Port, configVal) - if err != nil { - fmt.Printf("%s\n", err) - os.Exit(exitFail) - - } // Process non-config commands - err = nil var rsp notecard.Request // The timouts in the note-go library are set under the assumption that @@ -576,6 +571,12 @@ func main() { rsp, err = card.TransactionRequest(req) } } + if !actionVerbose { + if err == nil { + rspJSON, _ := note.JSONMarshal(rsp) + fmt.Printf("%s\n", rspJSON) + } + } if err == nil && actionOutput != "" && rsp.Payload != nil { err = ioutil.WriteFile(actionOutput, *rsp.Payload, 0644) } @@ -653,8 +654,12 @@ func main() { // Process errors if err != nil { + if actionRequest != "" && !actionVerbose { + fmt.Printf("{\"err\":%s}\n", strconv.Quote(err.Error())) + } else { fmt.Printf("%s\n", err) os.Exit(exitFail) + } } // Success