fix democoind init. use rootCmd

This commit is contained in:
Ethan Buchman 2018-04-05 13:41:11 +03:00
parent c74c57a2f0
commit 4dfc5c0852
3 changed files with 28 additions and 38 deletions

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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
}