console: fix output, closes #93

This commit is contained in:
Zach Ramsay 2017-10-23 19:35:02 -04:00
parent 3330cb4856
commit 36de70be10
1 changed files with 10 additions and 6 deletions

View File

@ -259,7 +259,7 @@ func cmdBatch(cmd *cobra.Command, args []string) {
func cmdConsole(cmd *cobra.Command, args []string) {
for {
fmt.Printf("\n> ")
fmt.Printf("> ")
bufReader := bufio.NewReader(os.Stdin)
line, more, err := bufReader.ReadLine()
if more {
@ -454,12 +454,16 @@ func printResponse(cmd *cobra.Command, args []string, rsp response) {
fmt.Println(">", cmd.Use, strings.Join(args, " "))
}
if !rsp.Code.IsOK() {
fmt.Printf("-> code: %s\n", rsp.Code.String())
}
// Always print the status code.
fmt.Printf("-> code: %s\n", rsp.Code.String())
if len(rsp.Data) != 0 {
fmt.Printf("-> data: %s\n", rsp.Data)
fmt.Printf("-> data.hex: %X\n", rsp.Data)
// Do no print this line when using the commit command
// because the string comes out as gibberish
if cmd.Use != "commit" {
fmt.Printf("-> data: %s\n", rsp.Data)
}
fmt.Printf("-> data.hex: 0x%X\n", rsp.Data)
}
if rsp.Log != "" {
fmt.Printf("-> log: %s\n", rsp.Log)