cosmos-sdk/server/export.go

29 lines
635 B
Go
Raw Normal View History

2018-04-26 08:53:07 -07:00
package server
import (
"fmt"
2018-04-27 17:00:33 -07:00
2018-04-26 08:53:07 -07:00
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/cosmos/cosmos-sdk/wire"
)
// ExportCmd dumps app state to JSON
2018-04-27 17:36:11 -07:00
func ExportCmd(ctx *Context, cdc *wire.Codec, appExporter AppExporter) *cobra.Command {
2018-04-27 17:00:33 -07:00
return &cobra.Command{
2018-04-26 08:53:07 -07:00
Use: "export",
Short: "Export state to JSON",
2018-04-27 17:00:33 -07:00
RunE: func(cmd *cobra.Command, args []string) error {
home := viper.GetString("home")
appState, err := appExporter(home, ctx.Logger)
if err != nil {
return errors.Errorf("Error exporting state: %v\n", err)
}
2018-04-27 17:36:11 -07:00
fmt.Println(string(appState))
2018-04-27 17:00:33 -07:00
return nil
},
2018-04-26 08:53:07 -07:00
}
}