93 lines
2.5 KiB
Go
93 lines
2.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/tendermint/abci/version"
|
|
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"
|
|
noncecmd "github.com/tendermint/basecoin/modules/nonce/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.
|
|
`,
|
|
}
|
|
|
|
// VersionCmd - command to show the application version
|
|
var VersionCmd = &cobra.Command{
|
|
Use: "version",
|
|
Short: "Show version info",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
fmt.Println(version.Version)
|
|
},
|
|
}
|
|
|
|
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,
|
|
)
|
|
proofs.TxPresenters.Register("base", txcmd.BaseTxPresenter{})
|
|
|
|
// set up the middleware
|
|
txcmd.Middleware = txcmd.Wrappers{
|
|
feecmd.FeeWrapper{},
|
|
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,
|
|
)
|
|
|
|
// 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,
|
|
VersionCmd,
|
|
auto.AutoCompleteCmd,
|
|
)
|
|
|
|
cmd := cli.PrepareMainCmd(BaseCli, "BC", os.ExpandEnv("$HOME/.basecli"))
|
|
cmd.Execute()
|
|
}
|