Skip to content

Commit

Permalink
fix: pruning cmd default directory (#103)
Browse files Browse the repository at this point in the history
Co-authored-by: zakir <[email protected]>
  • Loading branch information
devon-chain and zakir-code authored Oct 27, 2023
1 parent 9a61311 commit 210211b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"errors"
"fmt"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -114,7 +115,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig, defa
tmcli.NewCompletionCmd(rootCmd, true),
testnetCmd(encodingConfig),
configCmd(),
pruning.PruningCmd(myAppCreator.newApp),
pruningCommand(myAppCreator.newApp, defaultNodeHome),
)

// add keybase, auxiliary RPC, query, and tx child commands
Expand Down Expand Up @@ -207,6 +208,22 @@ func txCommand() *cobra.Command {
return cmd
}

func pruningCommand(appCreator servertypes.AppCreator, nodeHome string) *cobra.Command {
pruningCmd := pruning.PruningCmd(appCreator)
homeFlag := pruningCmd.Flag(flags.FlagHome)
homeFlag.DefValue = nodeHome
if err := homeFlag.Value.Set(nodeHome); err != nil {
panic(err)
}
dbBackend := pruningCmd.Flag(pruning.FlagAppDBBackend)
dbBackend.DefValue = string(dbm.GoLevelDBBackend)
if err := dbBackend.Value.Set(string(dbm.GoLevelDBBackend)); err != nil {
panic(err)
}
pruningCmd.Example = fmt.Sprintf(`$ %s prune --pruning custom --pruning-keep-recent 100`, fxtypes.Name)
return pruningCmd
}

type appCreator struct {
encCfg app.EncodingConfig
}
Expand Down

0 comments on commit 210211b

Please sign in to comment.