Files
wasmd/x/wasm/client/cli/utils.go
Jacob Gadikian 8627f85275 style: lint wasmd in the same manner as cosmos-sdk (#1537)
* golangci-lint run ./... --fix

* linting completed

* use the CosmWasm repo as part of the gci config
2023-07-31 15:53:20 +02:00

35 lines
824 B
Go

package cli
import (
"os"
"path/filepath"
tmcmd "github.com/cometbft/cometbft/cmd/cometbft/commands"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/server"
)
// ExtendUnsafeResetAllCmd - also clear wasm dir
func ExtendUnsafeResetAllCmd(rootCmd *cobra.Command) {
unsafeResetCmd := tmcmd.ResetAllCmd.Use
for _, branchCmd := range rootCmd.Commands() {
if branchCmd.Use != "tendermint" {
continue
}
for _, cmd := range branchCmd.Commands() {
if cmd.Use == unsafeResetCmd {
serverRunE := cmd.RunE
cmd.RunE = func(cmd *cobra.Command, args []string) error {
if err := serverRunE(cmd, args); err != nil {
return nil
}
serverCtx := server.GetServerContextFromCmd(cmd)
return os.RemoveAll(filepath.Join(serverCtx.Config.RootDir, "wasm"))
}
return
}
}
}
}