cosmos-sdk/client/snapshot/delete.go
Marko e6e1a853de
refactor(core,server): make commands not rely on server context (#20422)
Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
2024-05-28 13:07:36 +00:00

38 lines
758 B
Go

package snapshot
import (
"strconv"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
)
func DeleteSnapshotCmd() *cobra.Command {
return &cobra.Command{
Use: "delete <height> <format>",
Short: "Delete a local snapshot",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
viper := client.GetViperFromCmd(cmd)
height, err := strconv.ParseUint(args[0], 10, 64)
if err != nil {
return err
}
format, err := strconv.ParseUint(args[1], 10, 32)
if err != nil {
return err
}
snapshotStore, err := server.GetSnapshotStore(viper)
if err != nil {
return err
}
return snapshotStore.Delete(height, uint32(format))
},
}
}