Skip to content

Commit

Permalink
Cosmos POC: Clean up CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
arturalbov authored and hleb-albau committed Sep 27, 2018
1 parent fc51a4a commit 231a5b3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 33 deletions.
4 changes: 2 additions & 2 deletions cosmos/poc/commands/getlinks.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

// GetAccountCmd returns a query account that will display the state of the
// account at a given address.
func GetLinksCmd(cdc *wire.Codec) *cobra.Command {
func GetLinksCmd(storeName string, cdc *wire.Codec) *cobra.Command {
return &cobra.Command{
Use: "links [cid]",
Short: "Query cid links",
Expand All @@ -27,7 +27,7 @@ func GetLinksCmd(cdc *wire.Codec) *cobra.Command {

cliCtx := context.NewCLIContext().WithCodec(cdc)

res, err := cliCtx.QueryStore(key, "link")
res, err := cliCtx.QueryStore(key, storeName)
if err != nil || len(res) == 0 {
return err
}
Expand Down
48 changes: 17 additions & 31 deletions cosmos/poc/cyberdcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@ import (
"github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cybercongress/cyberd/cosmos/poc/app"
"github.com/cosmos/cosmos-sdk/version"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
"github.com/cybercongress/cyberd/cosmos/poc/app"
cyberdcmd "github.com/cybercongress/cyberd/cosmos/poc/commands"
ibccmd "github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/libs/cli"
)

// rootCmd is the entry point for this binary
// cyberdcli is the entry point for this binary
var (
rootCmd = &cobra.Command{
cyberdcli = &cobra.Command{
Use: "cyberdcli",
Short: "Cyberd light-client",
Short: "Cyberd node client",
}
)

Expand All @@ -38,46 +36,34 @@ func main() {
// the below functions and eliminate global vars, like we do
// with the cdc.

// add standard rpc, and tx commands
rpc.AddCommands(rootCmd)
rootCmd.AddCommand(client.LineBreak)
tx.AddCommands(rootCmd, cdc)
rootCmd.AddCommand(client.LineBreak)
rpc.AddCommands(cyberdcli) // Node management commands
cyberdcli.AddCommand(client.LineBreak)
tx.AddCommands(cyberdcli, cdc) // Txs info commands
cyberdcli.AddCommand(client.LineBreak)
cyberdcli.AddCommand(rpc.BlockCommand()) // Block info command
cyberdcli.AddCommand(client.LineBreak)

// add query/post commands (custom to binary)
rootCmd.AddCommand(
cyberdcli.AddCommand(
client.GetCommands(
stakecmd.GetCmdQueryValidator("stake", cdc),
stakecmd.GetCmdQueryValidators("stake", cdc),
stakecmd.GetCmdQueryDelegation("stake", cdc),
stakecmd.GetCmdQueryDelegations("stake", cdc),
authcmd.GetAccountCmd("acc", cdc, app.GetAccountDecoder(cdc)),
cyberdcmd.GetLinksCmd(cdc),
cyberdcmd.GetLinksCmd("link", cdc),
)...)

rootCmd.AddCommand(
cyberdcli.AddCommand(
client.PostCommands(
cyberdcmd.LinkTxCmd(cdc),
bankcmd.SendTxCmd(cdc),
ibccmd.IBCTransferCmd(cdc),
ibccmd.IBCRelayCmd(cdc),
stakecmd.GetCmdCreateValidator(cdc),
stakecmd.GetCmdEditValidator(cdc),
stakecmd.GetCmdDelegate(cdc),
stakecmd.GetCmdUnbond("stake", cdc),
)...)

// add proxy, version and key info
rootCmd.AddCommand(
cyberdcli.AddCommand(
client.LineBreak,
lcd.ServeCommand(cdc),
keys.Commands(),
lcd.ServeCommand(cdc), // Commands to start local rpc proxy to node
keys.Commands(), // Commands to generate and handle keys
client.LineBreak,
version.VersionCmd,
)

// prepare and add flags
executor := cli.PrepareMainCmd(rootCmd, "CBD", os.ExpandEnv("$HOME/.cyberdcli"))
executor := cli.PrepareMainCmd(cyberdcli, "CBD", os.ExpandEnv("$HOME/.cyberdcli"))
err := executor.Execute()
if err != nil {
// Note: Handle with #870
Expand Down
1 change: 1 addition & 0 deletions cosmos/poc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
github.com/cosmos/cosmos-sdk v0.24.2 h1:4NbgiXVPKjBpJRkZ1LnMxaz6EV+OCguFXy9Y+rT5ItY=
github.com/cosmos/cosmos-sdk v0.24.2/go.mod h1:JrX/JpJunJQXBI5PEX2zELHMFzQr/159jDjIhesOh2c=
github.com/cybercongress/cyberd v0.0.0-20180924154316-73930bbeebb1 h1:q4NHkuD56j5pUzyvjVWo1qELi6gKyB7cts7wb2bwxL0=
github.com/cybercongress/cyberd v0.0.0-20180925174400-fc51a4a10dbc h1:Jf8Skbd5z0NPwTGKYcZRHJot3DCwKhKhxvKElDsO7oA=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ebuchman/fail-test v0.0.0-20170303061230-95f809107225 h1:7TXT8REobzZUI9GzsRtAD29efTY/HgKRU2xYnV1zlaM=
Expand Down

0 comments on commit 231a5b3

Please sign in to comment.