cosmos-sdk/examples/basecoin/cmd/basecli/main.go

81 lines
1.9 KiB
Go
Raw Normal View History

2018-02-22 06:33:34 -08:00
package main
import (
"errors"
"os"
"github.com/spf13/cobra"
"github.com/tendermint/tmlibs/cli"
"github.com/cosmos/cosmos-sdk/client"
2018-02-22 08:20:25 -08:00
"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"
2018-03-03 11:41:43 -08:00
coolcmd "github.com/cosmos/cosmos-sdk/examples/basecoin/x/cool/commands"
2018-02-22 06:33:34 -08:00
"github.com/cosmos/cosmos-sdk/version"
2018-02-28 17:57:38 -08:00
authcmd "github.com/cosmos/cosmos-sdk/x/auth/commands"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/commands"
2018-02-28 17:57:38 -08:00
"github.com/cosmos/cosmos-sdk/examples/basecoin/app"
"github.com/cosmos/cosmos-sdk/examples/basecoin/types"
2018-02-22 06:33:34 -08:00
)
// gaiacliCmd is the entry point for this binary
var (
basecliCmd = &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
2018-02-28 17:57:38 -08:00
// get the codec
cdc := app.MakeCodec()
// add standard rpc, and tx commands
rpc.AddCommands(basecliCmd)
basecliCmd.AddCommand(client.LineBreak)
2018-02-28 17:57:38 -08:00
tx.AddCommands(basecliCmd, cdc)
basecliCmd.AddCommand(client.LineBreak)
2018-02-22 09:15:01 -08:00
// add query/post commands (custom to binary)
2018-02-22 06:33:34 -08:00
basecliCmd.AddCommand(
client.GetCommands(
2018-02-28 17:57:38 -08:00
authcmd.GetAccountCmd("main", cdc, types.GetParseAccount(cdc)),
)...)
2018-02-22 06:33:34 -08:00
basecliCmd.AddCommand(
client.PostCommands(
2018-02-28 17:57:38 -08:00
bankcmd.SendTxCmd(cdc),
)...)
2018-03-03 11:41:43 -08:00
basecliCmd.AddCommand(
client.PostCommands(
2018-03-12 18:43:29 -07:00
coolcmd.QuizTxCmd(cdc),
2018-03-03 11:41:43 -08:00
)...)
basecliCmd.AddCommand(
client.PostCommands(
2018-03-12 17:37:50 -07:00
coolcmd.SetTrendTxCmd(cdc),
2018-03-03 11:41:43 -08:00
)...)
2018-02-22 06:33:34 -08:00
// add proxy, version and key info
basecliCmd.AddCommand(
client.LineBreak,
lcd.ServeCommand(),
2018-02-22 08:20:25 -08:00
keys.Commands(),
client.LineBreak,
2018-02-22 06:33:34 -08:00
version.VersionCmd,
)
// prepare and add flags
2018-02-22 08:20:25 -08:00
executor := cli.PrepareMainCmd(basecliCmd, "BC", os.ExpandEnv("$HOME/.basecli"))
2018-02-22 06:33:34 -08:00
executor.Execute()
}