From 4dfc5c085259de30f2f42d84c1e8aa4426e1ae85 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Thu, 5 Apr 2018 13:41:11 +0300 Subject: [PATCH] fix democoind init. use rootCmd --- examples/basecoin/cmd/basecli/main.go | 31 +++++++++++-------------- examples/democoin/cmd/democli/main.go | 31 +++++++++++-------------- examples/democoin/cmd/democoind/main.go | 4 ++-- 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/examples/basecoin/cmd/basecli/main.go b/examples/basecoin/cmd/basecli/main.go index a0152aee99..6271adcecd 100644 --- a/examples/basecoin/cmd/basecli/main.go +++ b/examples/basecoin/cmd/basecli/main.go @@ -1,7 +1,6 @@ package main import ( - "errors" "os" "github.com/spf13/cobra" @@ -24,18 +23,14 @@ import ( "github.com/cosmos/cosmos-sdk/examples/basecoin/types" ) -// gaiacliCmd is the entry point for this binary +// rootCmd is the entry point for this binary var ( - basecliCmd = &cobra.Command{ + rootCmd = &cobra.Command{ Use: "basecli", Short: "Basecoin light-client", } ) -func todoNotImplemented(_ *cobra.Command, _ []string) error { - return errors.New("TODO: Command not yet implemented") -} - func main() { // disable sorting cobra.EnableCommandSorting = false @@ -48,36 +43,36 @@ func main() { // with the cdc // add standard rpc, and tx commands - rpc.AddCommands(basecliCmd) - basecliCmd.AddCommand(client.LineBreak) - tx.AddCommands(basecliCmd, cdc) - basecliCmd.AddCommand(client.LineBreak) + rpc.AddCommands(rootCmd) + rootCmd.AddCommand(client.LineBreak) + tx.AddCommands(rootCmd, cdc) + rootCmd.AddCommand(client.LineBreak) // add query/post commands (custom to binary) - basecliCmd.AddCommand( + rootCmd.AddCommand( client.GetCommands( authcmd.GetAccountCmd("main", cdc, types.GetAccountDecoder(cdc)), )...) - basecliCmd.AddCommand( + rootCmd.AddCommand( client.PostCommands( bankcmd.SendTxCmd(cdc), )...) - basecliCmd.AddCommand( + rootCmd.AddCommand( client.PostCommands( ibccmd.IBCTransferCmd(cdc), )...) - basecliCmd.AddCommand( + rootCmd.AddCommand( client.PostCommands( ibccmd.IBCRelayCmd(cdc), simplestakingcmd.BondTxCmd(cdc), )...) - basecliCmd.AddCommand( + rootCmd.AddCommand( client.PostCommands( simplestakingcmd.UnbondTxCmd(cdc), )...) // add proxy, version and key info - basecliCmd.AddCommand( + rootCmd.AddCommand( client.LineBreak, lcd.ServeCommand(cdc), keys.Commands(), @@ -86,6 +81,6 @@ func main() { ) // prepare and add flags - executor := cli.PrepareMainCmd(basecliCmd, "BC", os.ExpandEnv("$HOME/.basecli")) + executor := cli.PrepareMainCmd(rootCmd, "BC", os.ExpandEnv("$HOME/.basecli")) executor.Execute() } diff --git a/examples/democoin/cmd/democli/main.go b/examples/democoin/cmd/democli/main.go index 602e5478e9..bf499458be 100644 --- a/examples/democoin/cmd/democli/main.go +++ b/examples/democoin/cmd/democli/main.go @@ -1,7 +1,6 @@ package main import ( - "errors" "os" "github.com/spf13/cobra" @@ -24,18 +23,14 @@ import ( "github.com/cosmos/cosmos-sdk/examples/democoin/types" ) -// gaiacliCmd is the entry point for this binary +// rootCmd is the entry point for this binary var ( - democliCmd = &cobra.Command{ + rootCmd = &cobra.Command{ Use: "democli", Short: "Democoin light-client", } ) -func todoNotImplemented(_ *cobra.Command, _ []string) error { - return errors.New("TODO: Command not yet implemented") -} - func main() { // disable sorting cobra.EnableCommandSorting = false @@ -48,36 +43,36 @@ func main() { // with the cdc // add standard rpc, and tx commands - rpc.AddCommands(democliCmd) - democliCmd.AddCommand(client.LineBreak) - tx.AddCommands(democliCmd, cdc) - democliCmd.AddCommand(client.LineBreak) + rpc.AddCommands(rootCmd) + rootCmd.AddCommand(client.LineBreak) + tx.AddCommands(rootCmd, cdc) + rootCmd.AddCommand(client.LineBreak) // add query/post commands (custom to binary) - democliCmd.AddCommand( + rootCmd.AddCommand( client.GetCommands( authcmd.GetAccountCmd("main", cdc, types.GetAccountDecoder(cdc)), )...) - democliCmd.AddCommand( + rootCmd.AddCommand( client.PostCommands( bankcmd.SendTxCmd(cdc), )...) - democliCmd.AddCommand( + rootCmd.AddCommand( client.PostCommands( ibccmd.IBCTransferCmd(cdc), )...) - democliCmd.AddCommand( + rootCmd.AddCommand( client.PostCommands( ibccmd.IBCRelayCmd(cdc), simplestakingcmd.BondTxCmd(cdc), )...) - democliCmd.AddCommand( + rootCmd.AddCommand( client.PostCommands( simplestakingcmd.UnbondTxCmd(cdc), )...) // add proxy, version and key info - democliCmd.AddCommand( + rootCmd.AddCommand( client.LineBreak, lcd.ServeCommand(cdc), keys.Commands(), @@ -86,6 +81,6 @@ func main() { ) // prepare and add flags - executor := cli.PrepareMainCmd(democliCmd, "BC", os.ExpandEnv("$HOME/.democli")) + executor := cli.PrepareMainCmd(rootCmd, "BC", os.ExpandEnv("$HOME/.democli")) executor.Execute() } diff --git a/examples/democoin/cmd/democoind/main.go b/examples/democoin/cmd/democoind/main.go index 04436eec2e..6fc5930678 100644 --- a/examples/democoin/cmd/democoind/main.go +++ b/examples/democoin/cmd/democoind/main.go @@ -22,7 +22,7 @@ var ( context = server.NewContext(nil, nil) rootCmd = &cobra.Command{ Use: "democoind", - Short: "Gaia Daemon (server)", + Short: "Democoin Daemon (server)", PersistentPreRunE: server.PersistentPreRunEFn(context), } ) @@ -35,7 +35,7 @@ func defaultAppState(args []string, addr sdk.Address, coinDenom string) (json.Ra return nil, err } var jsonMap map[string]json.RawMessage - err = json.Unmarshal(baseJSON, jsonMap) + err = json.Unmarshal(baseJSON, &jsonMap) if err != nil { return nil, err }