Skip to content

Commit

Permalink
Merge branch 'feat/executor' of https://github.com/initia-labs/opinit…
Browse files Browse the repository at this point in the history
…-bots-go into feat/executor
  • Loading branch information
beer-1 committed Aug 6, 2024
2 parents a62d73d + 19b994c commit 2404bfb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/opinitd/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func keysAddCmd(ctx *cmdContext) *cobra.Command {
Example: strings.TrimSpace(`
$ keys add localnet key1
$ keys add l2 key2 --bech32 celestia
$ keys add l2 key2 --restore mnemonic.txt`),
$ keys add l2 key2 --recover --source mnemonic.txt`),
RunE: func(cmd *cobra.Command, args []string) error {
chainId := args[0]
keyName := args[1]
Expand Down
18 changes: 0 additions & 18 deletions cmd/opinitd/main.go

This file was deleted.

37 changes: 37 additions & 0 deletions cmd/opinitd/reset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"os"
"path"

"github.com/spf13/cobra"

bottypes "github.com/initia-labs/opinit-bots-go/bot/types"
)

func resetStateCmd(ctx *cmdContext) *cobra.Command {
cmd := &cobra.Command{
Use: "reset-db [bot-name]",
Args: cobra.ExactArgs(1),
Short: "Reset a bot's db.",
Long: `Reset a bot's db.
`,
RunE: func(cmd *cobra.Command, args []string) error {
botType := bottypes.BotTypeFromString(args[0])
switch botType {
case bottypes.BotTypeExecutor:
dbPath := path.Join(ctx.homePath, string(botType))
err := os.RemoveAll(dbPath + ".db")
if err != nil {
return err
}
err = os.Remove(path.Join(ctx.homePath, "batch"))
if err != nil {
return err
}
}
return nil
},
}
return cmd
}
1 change: 1 addition & 0 deletions cmd/opinitd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func NewRootCmd() *cobra.Command {
initCmd(ctx),
startCmd(ctx),
keysCmd(ctx),
resetStateCmd(ctx),
version.NewVersionCommand(),
)

Expand Down

0 comments on commit 2404bfb

Please sign in to comment.