0g-chain/cmd/kvcli/main.go

81 lines
1.9 KiB
Go
Raw Normal View History

2018-05-25 13:46:33 +00:00
package main
import (
"os"
"github.com/spf13/cobra"
"github.com/tendermint/tmlibs/cli"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/version"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
2018-06-16 16:21:13 +00:00
"github.com/kava-labs/kava/internal/app"
"github.com/kava-labs/kava/internal/types"
2018-05-25 13:46:33 +00:00
)
// rootCmd is the entry point for this binary
var (
rootCmd = &cobra.Command{
2018-06-16 21:34:07 +00:00
Use: "kvcli",
Short: "Kava Light-Client",
2018-05-25 13:46:33 +00:00
}
)
func main() {
// disable sorting
cobra.EnableCommandSorting = false
// get the codec
cdc := app.MakeCodec()
// TODO: setup keybase, viper object, etc. to be passed into
// the below functions and eliminate global vars, like we do
// with the cdc
// add standard rpc, and tx commands
rpc.AddCommands(rootCmd)
rootCmd.AddCommand(client.LineBreak)
tx.AddCommands(rootCmd, cdc)
rootCmd.AddCommand(client.LineBreak)
// add query/post commands (custom to binary)
rootCmd.AddCommand(
client.GetCommands(
authcmd.GetAccountCmd("acc", cdc, types.GetAccountDecoder(cdc)),
)...)
rootCmd.AddCommand(
client.PostCommands(
bankcmd.SendTxCmd(cdc),
ibccmd.IBCTransferCmd(cdc),
ibccmd.IBCRelayCmd(cdc),
2018-06-16 21:34:07 +00:00
stakecmd.GetCmdCreateValidator(cdc),
stakecmd.GetCmdEditValidator(cdc),
2018-05-25 13:46:33 +00:00
stakecmd.GetCmdDelegate(cdc),
stakecmd.GetCmdUnbond(cdc),
)...)
// add proxy, version and key info
rootCmd.AddCommand(
client.LineBreak,
lcd.ServeCommand(cdc),
keys.Commands(),
client.LineBreak,
version.VersionCmd,
)
// prepare and add flags
2018-06-16 21:34:07 +00:00
executor := cli.PrepareMainCmd(rootCmd, "KV", os.ExpandEnv("$HOME/.kvcli"))
2018-05-25 13:46:33 +00:00
executor.Execute()
}