cosmos-sdk/client/rpc/status.go

41 lines
758 B
Go
Raw Normal View History

package rpc
import (
"fmt"
"github.com/spf13/cobra"
wire "github.com/tendermint/go-wire"
"github.com/cosmos/cosmos-sdk/client"
)
func statusCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "status",
Short: "Query remote node for status",
RunE: checkStatus,
}
cmd.Flags().StringP(client.FlagNode, "n", "tcp://localhost:46657", "Node to connect to")
return cmd
}
func checkStatus(cmd *cobra.Command, args []string) error {
// get the node
2018-02-28 15:26:39 -08:00
node, err := client.GetNode()
if err != nil {
return err
}
res, err := node.Status()
if err != nil {
return err
}
output, err := wire.MarshalJSON(res)
2018-02-28 06:36:21 -08:00
// output, err := json.MarshalIndent(res, " ", "")
if err != nil {
return err
}
fmt.Println(string(output))
return nil
}