cosmos-sdk/cmd/gaiacli/main.go

78 lines
1.6 KiB
Go

package main
import (
"errors"
"os"
"github.com/spf13/cobra"
"github.com/tendermint/tmlibs/cli"
"github.com/cosmos/cosmos-sdk/version"
)
const (
flagTo = "to"
flagAmount = "amount"
flagFee = "fee"
)
// rootCmd is the entry point for this binary
var (
rootCmd = &cobra.Command{
Use: "gaiacli",
Short: "Gaia light-client",
}
lineBreak = &cobra.Command{Run: func(*cobra.Command, []string) {}}
getAccountCmd = &cobra.Command{
Use: "account <address>",
Short: "Query account balance",
RunE: todoNotImplemented,
}
)
func todoNotImplemented(_ *cobra.Command, _ []string) error {
return errors.New("TODO: Command not yet implemented")
}
func postSendCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "send",
Short: "Create and sign a send tx",
RunE: todoNotImplemented,
}
cmd.Flags().String(flagTo, "", "Address to send coins")
cmd.Flags().String(flagAmount, "", "Amount of coins to send")
cmd.Flags().String(flagFee, "", "Fee to pay along with transaction")
return cmd
}
func main() {
// disable sorting
cobra.EnableCommandSorting = false
// generic client commands
AddClientCommands(rootCmd)
// query commands (custom to binary)
rootCmd.AddCommand(
GetCommands(getAccountCmd)...)
// post tx commands (custom to binary)
rootCmd.AddCommand(
PostCommands(postSendCommand())...)
// add proxy, version and key info
rootCmd.AddCommand(
lineBreak,
serveCommand(),
KeyCommands(),
lineBreak,
version.VersionCmd,
)
// prepare and add flags
executor := cli.PrepareBaseCmd(rootCmd, "GA", os.ExpandEnv("$HOME/.gaiacli"))
executor.Execute()
}