cosmos-sdk/cmd/basecli/main.go

93 lines
2.5 KiB
Go
Raw Normal View History

2017-04-27 14:17:06 -07:00
package main
import (
"fmt"
2017-04-27 14:17:06 -07:00
"os"
"github.com/spf13/cobra"
2017-05-16 16:14:31 -07:00
"github.com/tendermint/abci/version"
2017-04-27 14:17:06 -07:00
keycmd "github.com/tendermint/go-crypto/cmd"
"github.com/tendermint/tmlibs/cli"
2017-07-18 12:57:37 -07:00
"github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/basecoin/client/commands/auto"
2017-07-18 12:57:37 -07:00
"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"
2017-04-27 14:17:06 -07:00
)
2017-07-05 03:57:52 -07:00
// BaseCli - main basecoin client command
2017-04-27 14:17:06 -07:00
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)
},
}
2017-05-01 00:05:54 -07:00
func main() {
2017-04-27 14:17:06 -07:00
commands.AddBasicFlags(BaseCli)
2017-06-16 01:57:45 -07:00
// Prepare queries
2017-07-05 03:57:52 -07:00
proofs.RootCmd.AddCommand(
// These are default parsers, but optional in your app (you can remove key)
proofs.TxCmd,
proofs.KeyCmd,
coincmd.AccountQueryCmd,
noncecmd.NonceQueryCmd,
2017-07-05 03:57:52 -07:00
)
proofs.TxPresenters.Register("base", txcmd.BaseTxPresenter{})
2017-06-15 03:27:55 -07:00
// 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(
2017-07-05 03:57:52 -07:00
// This is the default transaction, optional in your app
coincmd.SendTxCmd,
2017-07-05 03:57:52 -07:00
)
2017-04-27 14:17:06 -07:00
2017-06-16 01:57:45 -07:00
// Set up the various commands to use
2017-05-01 00:05:54 -07:00
BaseCli.AddCommand(
commands.InitCmd,
2017-06-15 03:27:55 -07:00
commands.ResetCmd,
keycmd.RootCmd,
2017-05-01 00:05:54 -07:00
seeds.RootCmd,
rpccmd.RootCmd,
2017-07-05 03:57:52 -07:00
proofs.RootCmd,
txcmd.RootCmd,
proxy.RootCmd,
VersionCmd,
auto.AutoCompleteCmd,
)
2017-05-01 00:05:54 -07:00
cmd := cli.PrepareMainCmd(BaseCli, "BC", os.ExpandEnv("$HOME/.basecli"))
cmd.Execute()
2017-04-27 14:17:06 -07:00
}