diff --git a/cmd/basecli/main.go b/cmd/basecli/main.go index 753e149fd4..0506882a27 100644 --- a/cmd/basecli/main.go +++ b/cmd/basecli/main.go @@ -14,7 +14,6 @@ import ( "github.com/tendermint/tmlibs/cli" bcmd "github.com/tendermint/basecoin/cmd/basecli/commands" - bcount "github.com/tendermint/basecoin/cmd/basecli/counter" ) // BaseCli represents the base command when called without any subcommands @@ -34,21 +33,15 @@ func main() { // Prepare queries pr := proofs.RootCmd - // These are default parsers, but you optional in your app + // These are default parsers, but optional in your app (you can remove key) pr.AddCommand(proofs.TxCmd) pr.AddCommand(proofs.KeyCmd) pr.AddCommand(bcmd.AccountQueryCmd) - pr.AddCommand(bcount.CounterQueryCmd) - // Here is how you add custom txs... but don't really add counter in your app + // you will always want this for the base send command proofs.TxPresenters.Register("base", bcmd.BaseTxPresenter{}) tr := txs.RootCmd tr.AddCommand(bcmd.SendTxCmd) - tr.AddCommand(bcount.CounterTxCmd) - - // TODO - // txs.Register("send", bcmd.SendTxMaker{}) - // txs.Register("counter", bcount.CounterTxMaker{}) // Set up the various commands to use BaseCli.AddCommand( diff --git a/cmd/basecli/counter/counter.go b/cmd/countercli/commands/counter.go similarity index 99% rename from cmd/basecli/counter/counter.go rename to cmd/countercli/commands/counter.go index 60f949fce2..22064e08cb 100644 --- a/cmd/basecli/counter/counter.go +++ b/cmd/countercli/commands/counter.go @@ -1,4 +1,4 @@ -package counter +package commands import ( "github.com/spf13/cobra" diff --git a/cmd/basecli/counter/query.go b/cmd/countercli/commands/query.go similarity index 97% rename from cmd/basecli/counter/query.go rename to cmd/countercli/commands/query.go index 9a86df6257..751f7a11b0 100644 --- a/cmd/basecli/counter/query.go +++ b/cmd/countercli/commands/query.go @@ -1,4 +1,4 @@ -package counter +package commands import ( "github.com/spf13/cobra" diff --git a/cmd/countercli/main.go b/cmd/countercli/main.go new file mode 100644 index 0000000000..57204d3fb6 --- /dev/null +++ b/cmd/countercli/main.go @@ -0,0 +1,64 @@ +package main + +import ( + "os" + + "github.com/spf13/cobra" + + keycmd "github.com/tendermint/go-crypto/cmd" + "github.com/tendermint/light-client/commands" + "github.com/tendermint/light-client/commands/proofs" + "github.com/tendermint/light-client/commands/proxy" + "github.com/tendermint/light-client/commands/seeds" + "github.com/tendermint/light-client/commands/txs" + "github.com/tendermint/tmlibs/cli" + + bcmd "github.com/tendermint/basecoin/cmd/basecli/commands" + bcount "github.com/tendermint/basecoin/cmd/countercli/commands" +) + +// BaseCli represents the base command when called without any subcommands +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 + pr := proofs.RootCmd + // These are default parsers, but you optional in your app + pr.AddCommand(proofs.TxCmd) + pr.AddCommand(proofs.KeyCmd) + pr.AddCommand(bcmd.AccountQueryCmd) + + // IMPORTANT: here is how you add custom query commands in your app + pr.AddCommand(bcount.CounterQueryCmd) + + proofs.TxPresenters.Register("base", bcmd.BaseTxPresenter{}) + tr := txs.RootCmd + tr.AddCommand(bcmd.SendTxCmd) + + // IMPORTANT: here is how you add custom tx construction for your app + tr.AddCommand(bcount.CounterTxCmd) + + // Set up the various commands to use + BaseCli.AddCommand( + commands.InitCmd, + commands.ResetCmd, + keycmd.RootCmd, + seeds.RootCmd, + pr, + tr, + proxy.RootCmd) + + cmd := cli.PrepareMainCmd(BaseCli, "BC", os.ExpandEnv("$HOME/.basecli")) + cmd.Execute() +}