2018-02-23 10:23:24 -08:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2018-03-03 18:00:28 -08:00
|
|
|
wire "github.com/tendermint/go-wire"
|
2018-02-23 10:23:24 -08:00
|
|
|
|
|
|
|
"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
|
|
|
|
}
|
2018-02-23 10:23:24 -08:00
|
|
|
res, err := node.Status()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-03-03 18:00:28 -08:00
|
|
|
output, err := wire.MarshalJSON(res)
|
2018-02-28 06:36:21 -08:00
|
|
|
// output, err := json.MarshalIndent(res, " ", "")
|
2018-02-23 10:23:24 -08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
fmt.Println(string(output))
|
|
|
|
return nil
|
|
|
|
}
|