Extend the query command

This commit is contained in:
Adrian Brink 2017-05-13 18:37:00 +02:00
parent b662bc7d34
commit 4674bf96b0

View File

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"strconv"
"strings" "strings"
abcicli "github.com/tendermint/abci/client" abcicli "github.com/tendermint/abci/client"
@ -307,18 +308,36 @@ func cmdCommit(c *cli.Context) error {
// TODO: Make request and response support all fields. // TODO: Make request and response support all fields.
func cmdQuery(c *cli.Context) error { func cmdQuery(c *cli.Context) error {
args := c.Args() args := c.Args()
if len(args) != 1 { fmt.Println(len(args))
return errors.New("Command query takes 1 argument") if len(args) == 0 {
return errors.New("Command query takes 1 or more arguments")
} }
queryBytes, err := stringOrHexToBytes(c.Args()[0])
queryBytes, err := stringOrHexToBytes(args[0])
if err != nil { if err != nil {
return err return err
} }
var path = "/store"
if len(args) > 1 {
path = args[1]
}
var height uint64
if len(args) > 2 {
height, _ = strconv.ParseUint(args[2], 10, 64)
}
var prove = true
if len(args) > 3 {
prove, _ = strconv.ParseBool(args[3])
}
resQuery, err := client.QuerySync(types.RequestQuery{ resQuery, err := client.QuerySync(types.RequestQuery{
Data: queryBytes, Data: queryBytes,
Path: "/store", // TOOD expose Path: path,
Height: 0, // TODO expose Height: height,
//Prove: true, // TODO expose Prove: prove,
}) })
if err != nil { if err != nil {
return err return err