Merge pull request #119 from tendermint/93-fix-console-output

fix console output
This commit is contained in:
Zach 2017-10-26 07:58:16 -04:00 committed by GitHub
commit b5bdb6ec54
3 changed files with 32 additions and 14 deletions

View File

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

View File

@ -1,36 +1,44 @@
> echo hello > echo hello
-> code: OK
-> data: hello -> data: hello
-> data.hex: 68656C6C6F -> data.hex: 0x68656C6C6F
> info > info
-> code: OK
-> data: {"size":0} -> data: {"size":0}
-> data.hex: 7B2273697A65223A307D -> data.hex: 0x7B2273697A65223A307D
> commit > commit
-> code: OK
> deliver_tx "abc" > deliver_tx "abc"
-> code: OK
> info > info
-> code: OK
-> data: {"size":1} -> data: {"size":1}
-> data.hex: 7B2273697A65223A317D -> data.hex: 0x7B2273697A65223A317D
> commit > commit
-> data: IßÑ\ͬޮ—(ËûµèhŒ¥ -> code: OK
-> data.hex: 49DFD15CCDACDEAE9728CB01FBB5E8688CA58B91 -> data.hex: 0x49DFD15CCDACDEAE9728CB01FBB5E8688CA58B91
> query "abc" > query "abc"
-> code: OK
-> log: exists -> log: exists
-> height: 0 -> height: 0
-> value: abc -> value: abc
-> value.hex: 616263 -> value.hex: 616263
> deliver_tx "def=xyz" > deliver_tx "def=xyz"
-> code: OK
> commit > commit
-> data: p-³"€7?¿?Ÿ‰Ú* Î,Ö+ -> code: OK
-> data.hex: 70102DB32280373FBF3F9F89DA2A20CE2CD62B0B -> data.hex: 0x70102DB32280373FBF3F9F89DA2A20CE2CD62B0B
> query "def" > query "def"
-> code: OK
-> log: exists -> log: exists
-> height: 0 -> height: 0
-> value: xyz -> value: xyz

View File

@ -1,22 +1,28 @@
> set_option serial on > set_option serial on
-> code: OK
> check_tx 0x00 > check_tx 0x00
-> code: OK
> check_tx 0xff > check_tx 0xff
-> code: OK
> deliver_tx 0x00 > deliver_tx 0x00
-> code: OK
> check_tx 0x00 > check_tx 0x00
-> code: BadNonce -> code: BadNonce
-> log: Invalid nonce. Expected >= 1, got 0 -> log: Invalid nonce. Expected >= 1, got 0
> deliver_tx 0x01 > deliver_tx 0x01
-> code: OK
> deliver_tx 0x04 > deliver_tx 0x04
-> code: BadNonce -> code: BadNonce
-> log: Invalid nonce. Expected 2, got 4 -> log: Invalid nonce. Expected 2, got 4
> info > info
-> code: OK
-> data: {"hashes":0,"txs":2} -> data: {"hashes":0,"txs":2}
-> data.hex: 7B22686173686573223A302C22747873223A327D -> data.hex: 0x7B22686173686573223A302C22747873223A327D