move id command under net

This commit is contained in:
whyrusleeping 2019-07-22 10:20:07 -07:00
parent 57df9fdd9e
commit 4a34e20ffc
3 changed files with 22 additions and 29 deletions

View File

@ -61,7 +61,6 @@ func reqContext(cctx *cli.Context) context.Context {
var Commands = []*cli.Command{ var Commands = []*cli.Command{
chainCmd, chainCmd,
clientCmd, clientCmd,
idCmd,
minerCmd, minerCmd,
mpoolCmd, mpoolCmd,
netCmd, netCmd,

View File

@ -1,28 +0,0 @@
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
},
}

View File

@ -19,6 +19,7 @@ var netCmd = &cli.Command{
netPeers, netPeers,
netConnect, netConnect,
netListen, netListen,
netId,
}, },
} }
@ -95,6 +96,27 @@ var netConnect = &cli.Command{
}, },
} }
var netId = &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
},
}
// parseAddresses is a function that takes in a slice of string peer addresses // parseAddresses is a function that takes in a slice of string peer addresses
// (multiaddr + peerid) and returns a slice of properly constructed peers // (multiaddr + peerid) and returns a slice of properly constructed peers
func parseAddresses(ctx context.Context, addrs []string) ([]peer.AddrInfo, error) { func parseAddresses(ctx context.Context, addrs []string) ([]peer.AddrInfo, error) {