address Chris' comments

This commit is contained in:
Federico Kunze 2018-11-28 00:00:38 +01:00
parent 14154f71be
commit 7cf5da2f72
2 changed files with 15 additions and 2 deletions

View File

@ -32,7 +32,7 @@ func SearchTxCmd(cdc *codec.Codec) *cobra.Command {
Long: strings.TrimSpace(`
Search for transactions that match exactly the given tags. For example:
$ gaiacli query txs --tags <tag1>:<value1>&<tag2>:<value2>
$ gaiacli query txs --tags '<tag1>:<value1>&<tag2>:<value2>'
`),
RunE: func(cmd *cobra.Command, args []string) error {
tagsStr := viper.GetString(flagTags)
@ -48,7 +48,10 @@ $ gaiacli query txs --tags <tag1>:<value1>&<tag2>:<value2>
for _, tag := range tags {
if !strings.Contains(tag, ":") {
return fmt.Errorf("%s should be of the format <key>:<value>", tagsStr)
} else if strings.Count(tag, ":") > 1 {
return fmt.Errorf("%s should only contain one <key>:<value> pair", tagsStr)
}
keyValue := strings.Split(tag, ":")
tag = fmt.Sprintf("%s='%s'", keyValue[0], keyValue[1])
tmTags = append(tmTags, tag)

View File

@ -193,8 +193,18 @@ gaiacli tx broadcast --node=<node> signedSendTx.json
You can use the transaction search command to query for transactions that match a specific set of `tags`, which are added on every transaction.
Each tag is conformed by a key-value pair in the form of `<tag>:<value>`. Tags can also be combined to query for a more specific result using the `&` symbol.
The command for querying transactions using a `tag` is the following:
```bash
gaiacli query txs --tags=<tag1>:<value1>&<tag2>:<value2>
gaiacli query txs --tags='<tag>:<value>'
```
And for using multiple `tags`:
```bash
gaiacli query txs --tags='<tag1>:<value1>&<tag2>:<value2>'
```
::: tip Note