add AsTable method to print peer in a table

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-06-20 17:14:50 -04:00 committed by Jakub
parent fba5f56834
commit b7fd7b20ed
2 changed files with 5 additions and 1 deletions

View File

@ -17,6 +17,10 @@ func (p Peer) String() string {
type peerId string
func (p Peer) AsTable() string {
return fmt.Sprintf("%15s | what", p.Id)
}
// the ID is too long to display in full in most places
func (id peerId) String() string {
return fmt.Sprintf("%s...%s",

View File

@ -66,7 +66,7 @@ func writePeers(g *gocui.Gui, peers []Peer) {
}
v.Clear()
for _, peer := range peers {
fmt.Fprintf(v, "%v\n", peer)
fmt.Fprintf(v, "%s\n", peer.AsTable())
}
return nil
})