add an id command

This commit is contained in:
whyrusleeping 2019-07-20 14:55:51 -07:00
parent 13e217987b
commit 57df9fdd9e
2 changed files with 32 additions and 3 deletions

View File

@ -59,12 +59,13 @@ func reqContext(cctx *cli.Context) context.Context {
}
var Commands = []*cli.Command{
clientCmd,
chainCmd,
clientCmd,
idCmd,
minerCmd,
mpoolCmd,
netCmd,
versionCmd,
mpoolCmd,
minerCmd,
walletCmd,
createMinerCmd,
}

28
cli/id.go Normal file
View File

@ -0,0 +1,28 @@
package cli
import (
"fmt"
"gopkg.in/urfave/cli.v2"
)
var idCmd = &cli.Command{
Name: "id",
Usage: "Get node identity",
Action: func(cctx *cli.Context) error {
api, err := getAPI(cctx)
if err != nil {
return err
}
ctx := reqContext(cctx)
pid, err := api.ID(ctx)
if err != nil {
return err
}
fmt.Println(pid)
return nil
},
}