Browse Source

cmd/abci-cli: implement batch

Can now run batch which can be tested by:
```shell
echo -e "echo foo\necho blue" | abci-cli batch
```

giving
```shell
I[12-12|07:55:55.513] Starting socketClient
module=abci-client impl=socketClient
-> code: OK
-> data: foo
-> data.hex: 0x666F6F

-> code: OK
-> data: blue
-> data.hex: 0x626C7565

```
pull/1780/head
Emmanuel Odeke 7 years ago
parent
commit
5ea42475ce
1 changed files with 9 additions and 17 deletions
  1. +9
    -17
      cmd/abci-cli/abci-cli.go

+ 9
- 17
cmd/abci-cli/abci-cli.go View File

@ -359,14 +359,11 @@ func cmdBatch(cmd *cobra.Command, args []string) error {
return err
}
if len(line) > 0 { // prevents introduction of extra space leading to argument parse errors
args = strings.Split(string(line), " ")
}
if err := muxOnCommands(cmd, args); err != nil {
cmdArgs := persistentArgs(line)
if err := muxOnCommands(cmd, cmdArgs); err != nil {
return err
}
fmt.Println("")
fmt.Println()
}
return nil
}
@ -397,22 +394,14 @@ var (
)
func muxOnCommands(cmd *cobra.Command, pArgs []string) error {
if len(pArgs) < 1 && cmd.Use != "batch" {
if len(pArgs) < 2 {
return errBadPersistentArgs
}
subCommand, actualArgs := pArgs[0], pArgs[1:]
//if cmd.Use == "batch" {
// cmd.Use = subCommand
//}
subCommand, actualArgs := pArgs[1], pArgs[2:]
switch strings.ToLower(subCommand) {
case "batch":
fmt.Println("WTF")
return nil
return muxOnCommands(cmd, actualArgs)
case "check_tx":
return cmdCheckTx(cmd, actualArgs)
case "commit":
@ -438,6 +427,9 @@ func cmdUnimplemented(cmd *cobra.Command, args []string) error {
if err := cmd.Help(); err != nil {
msg = err.Error()
}
if len(args) > 0 {
msg += fmt.Sprintf(" args: [%s]", strings.Join(args, " "))
}
printResponse(cmd, args, response{
Code: codeBad,
Log: msg,


Loading…
Cancel
Save