Skip to content

Commit

Permalink
fix: add an encoder for swarm peering ls
Browse files Browse the repository at this point in the history
  • Loading branch information
TakashiMatsuda committed Aug 17, 2021
1 parent 7a57348 commit 6721d11
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/commands/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ var swarmPeeringLsCmd = &cmds.Command{
return cmds.EmitOnce(res, addrInfos{Peers: peers})
},
Type: addrInfos{},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, ai *addrInfos) error {
for _, info := range ai.Peers {
fmt.Fprintf(w, "%s \n", info.ID.String())
for _, addr := range info.Addrs {
fmt.Fprintf(w, "\t"+addr.String()+"\n")
}
}
return nil
}),
},
}

type addrInfos struct {
Expand Down

0 comments on commit 6721d11

Please sign in to comment.