Skip to content

Commit

Permalink
chore: small snapshot commands & docs improvement (backport cosmos#16404
Browse files Browse the repository at this point in the history
) (cosmos#16409)

Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
2 people authored and JeancarloBarrios committed Sep 28, 2024
1 parent 30ba418 commit 086573c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
1 change: 0 additions & 1 deletion client/snapshot/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ func Cmd(appCreator servertypes.AppCreator) *cobra.Command {
cmd := &cobra.Command{
Use: "snapshots",
Short: "Manage local snapshots",
Long: "Manage local snapshots",
}
cmd.AddCommand(
ListSnapshotsCmd,
Expand Down
6 changes: 2 additions & 4 deletions client/snapshot/export.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package snapshot

import (
"fmt"

"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -34,15 +32,15 @@ func ExportSnapshotCmd(appCreator servertypes.AppCreator) *cobra.Command {
height = app.CommitMultiStore().LastCommitID().Version
}

fmt.Printf("Exporting snapshot for height %d\n", height)
cmd.Printf("Exporting snapshot for height %d\n", height)

sm := app.SnapshotManager()
snapshot, err := sm.Create(uint64(height))
if err != nil {
return err
}

fmt.Printf("Snapshot created at height %d, format %d, chunks %d\n", snapshot.Height, snapshot.Format, snapshot.Chunks)
cmd.Printf("Snapshot created at height %d, format %d, chunks %d\n", snapshot.Height, snapshot.Format, snapshot.Chunks)
return nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion client/snapshot/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var ListSnapshotsCmd = &cobra.Command{
return fmt.Errorf("failed to list snapshots: %w", err)
}
for _, snapshot := range snapshots {
fmt.Println("height:", snapshot.Height, "format:", snapshot.Format, "chunks:", snapshot.Chunks)
cmd.Println("height:", snapshot.Height, "format:", snapshot.Format, "chunks:", snapshot.Chunks)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions client/snapshot/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const SnapshotFileName = "_snapshot"
func LoadArchiveCmd() *cobra.Command {
return &cobra.Command{
Use: "load <archive-file>",
Short: "Load a snapshot archive file into snapshot store",
Short: "Load a snapshot archive file (.tar.gz) into snapshot store",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := server.GetServerContextFromCmd(cmd)
Expand Down Expand Up @@ -70,7 +70,7 @@ func LoadArchiveCmd() *cobra.Command {

savedSnapshot, err := snapshotStore.Save(snapshot.Height, snapshot.Format, chunks)
if err != nil {
fmt.Println("failed to save snapshot", err)
cmd.Println("failed to save snapshot", err)
return
}
quitChan <- savedSnapshot
Expand Down
12 changes: 6 additions & 6 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,12 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo
return conf, nil
}

// AddCommands add server commands
func AddCommands[T types.Application](rootCmd *cobra.Command, appCreator types.AppCreator[T], opts StartCmdOptions[T]) {
cometCmd := &cobra.Command{
Use: "comet",
Aliases: []string{"cometbft", "tendermint"},
Short: "CometBFT subcommands",
// add server commands
func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator types.AppCreator, appExport types.AppExporter, addStartFlags types.ModuleInitFlags) {
tendermintCmd := &cobra.Command{
Use: "tendermint",
Aliases: []string{"comet", "cometbft"},
Short: "Tendermint subcommands",
}

cometCmd.AddCommand(
Expand Down

0 comments on commit 086573c

Please sign in to comment.