cosmos-sdk/cmd/basecli/main.go

94 lines
2.7 KiB
Go

package main
import (
"os"
"github.com/spf13/cobra"
keycmd "github.com/tendermint/go-crypto/cmd"
"github.com/tendermint/tmlibs/cli"
"github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/basecoin/client/commands/auto"
"github.com/tendermint/basecoin/client/commands/proofs"
"github.com/tendermint/basecoin/client/commands/proxy"
rpccmd "github.com/tendermint/basecoin/client/commands/rpc"
"github.com/tendermint/basecoin/client/commands/seeds"
txcmd "github.com/tendermint/basecoin/client/commands/txs"
authcmd "github.com/tendermint/basecoin/modules/auth/commands"
basecmd "github.com/tendermint/basecoin/modules/base/commands"
coincmd "github.com/tendermint/basecoin/modules/coin/commands"
feecmd "github.com/tendermint/basecoin/modules/fee/commands"
ibccmd "github.com/tendermint/basecoin/modules/ibc/commands"
noncecmd "github.com/tendermint/basecoin/modules/nonce/commands"
rolecmd "github.com/tendermint/basecoin/modules/roles/commands"
)
// BaseCli - main basecoin client command
var BaseCli = &cobra.Command{
Use: "basecli",
Short: "Light client for tendermint",
Long: `Basecli is an version of tmcli including custom logic to
present a nice (not raw hex) interface to the basecoin blockchain structure.
This is a useful tool, but also serves to demonstrate how one can configure
tmcli to work for any custom abci app.
`,
}
func main() {
commands.AddBasicFlags(BaseCli)
// Prepare queries
proofs.RootCmd.AddCommand(
// These are default parsers, but optional in your app (you can remove key)
proofs.TxQueryCmd,
proofs.KeyQueryCmd,
coincmd.AccountQueryCmd,
noncecmd.NonceQueryCmd,
rolecmd.RoleQueryCmd,
ibccmd.IBCQueryCmd,
)
proofs.TxPresenters.Register("base", txcmd.BaseTxPresenter{})
// set up the middleware
txcmd.Middleware = txcmd.Wrappers{
feecmd.FeeWrapper{},
rolecmd.RoleWrapper{},
noncecmd.NonceWrapper{},
basecmd.ChainWrapper{},
authcmd.SigWrapper{},
}
txcmd.Middleware.Register(txcmd.RootCmd.PersistentFlags())
// you will always want this for the base send command
txcmd.RootCmd.AddCommand(
// This is the default transaction, optional in your app
coincmd.SendTxCmd,
coincmd.CreditTxCmd,
// this enables creating roles
rolecmd.CreateRoleTxCmd,
// these are for handling ibc
ibccmd.RegisterChainTxCmd,
ibccmd.UpdateChainTxCmd,
ibccmd.PostPacketTxCmd,
)
// Set up the various commands to use
BaseCli.AddCommand(
commands.InitCmd,
commands.ResetCmd,
keycmd.RootCmd,
seeds.RootCmd,
rpccmd.RootCmd,
proofs.RootCmd,
txcmd.RootCmd,
proxy.RootCmd,
commands.VersionCmd,
auto.AutoCompleteCmd,
)
cmd := cli.PrepareMainCmd(BaseCli, "BC", os.ExpandEnv("$HOME/.basecli"))
cmd.Execute()
}