# HG changeset patch # User Mikael Berthe # Date 1521547986 -3600 # Node ID be28c23ace0e2410eb86c9c0033f6d8e6883017c # Parent ae9b3c28fab30c5d790e59081c5499f29fa3c49f Update PlainPrinter Add new types and fields to the plainprinter output. diff -r ae9b3c28fab3 -r be28c23ace0e printer/plainprinter.go --- a/printer/plainprinter.go Tue Mar 20 12:21:04 2018 +0100 +++ b/printer/plainprinter.go Tue Mar 20 13:13:06 2018 +0100 @@ -43,10 +43,11 @@ } switch o := obj.(type) { case []madon.Account, []madon.Attachment, []madon.Card, []madon.Context, - []madon.Instance, []madon.Mention, []madon.Notification, + []madon.Emoji, []madon.Instance, []madon.InstancePeer, + []madon.List, []madon.Mention, []madon.Notification, []madon.Relationship, []madon.Report, []madon.Results, - []madon.Status, []madon.StreamEvent, []madon.Tag, []madon.DomainName, - []*gomif.InstanceStatus: + []madon.Status, []madon.StreamEvent, []madon.Tag, + []madon.DomainName, []*gomif.InstanceStatus: return p.plainForeach(o, w, initialIndent) case *madon.DomainName: return p.plainPrintDomainName(o, w, initialIndent) @@ -68,10 +69,22 @@ return p.plainPrintContext(o, w, initialIndent) case madon.Context: return p.plainPrintContext(&o, w, initialIndent) + case *madon.Emoji: + return p.plainPrintEmoji(o, w, initialIndent) + case madon.Emoji: + return p.plainPrintEmoji(&o, w, initialIndent) case *madon.Instance: return p.plainPrintInstance(o, w, initialIndent) case madon.Instance: return p.plainPrintInstance(&o, w, initialIndent) + case *madon.InstancePeer: + return p.plainPrintInstancePeer(o, w, initialIndent) + case madon.InstancePeer: + return p.plainPrintInstancePeer(&o, w, initialIndent) + case *madon.List: + return p.plainPrintList(o, w, initialIndent) + case madon.List: + return p.plainPrintList(&o, w, initialIndent) case *madon.Notification: return p.plainPrintNotification(o, w, initialIndent) case madon.Notification: @@ -186,6 +199,7 @@ indentedPrint(w, indent, false, true, "Remote URL", "%s", a.RemoteURL) indentedPrint(w, indent, false, true, "Preview URL", "%s", a.PreviewURL) indentedPrint(w, indent, false, true, "Text URL", "%s", a.PreviewURL) + indentedPrint(w, indent, false, true, "Description", "%s", a.Description) return nil } @@ -210,12 +224,35 @@ return nil } +func (p *PlainPrinter) plainPrintEmoji(e *madon.Emoji, w io.Writer, indent string) error { + indentedPrint(w, indent, true, false, "Emoji shortcode", "%s", e.ShortCode) + indentedPrint(w, indent, false, false, "URL", "%s", e.URL) + return nil +} + func (p *PlainPrinter) plainPrintInstance(i *madon.Instance, w io.Writer, indent string) error { indentedPrint(w, indent, true, false, "Instance title", "%s", i.Title) indentedPrint(w, indent, false, true, "Description", "%s", html2string(i.Description)) indentedPrint(w, indent, false, true, "URL", "%s", i.URI) indentedPrint(w, indent, false, true, "Email", "%s", i.Email) indentedPrint(w, indent, false, true, "Version", "%s", i.Version) + if i.ContactAccount != nil { + c := i.ContactAccount + indentedPrint(w, indent+p.Indent, true, false, "Contact account ID", "%d (%s)", c.ID, c.Username) + indentedPrint(w, indent+p.Indent, false, false, "Contact user ID", "%s", c.Acct) + indentedPrint(w, indent+p.Indent, false, false, "Contact display name", "%s", c.DisplayName) + } + return nil +} + +func (p *PlainPrinter) plainPrintInstancePeer(i *madon.InstancePeer, w io.Writer, indent string) error { + indentedPrint(w, indent, true, false, "Peer", "%s", *i) + return nil +} + +func (p *PlainPrinter) plainPrintList(l *madon.List, w io.Writer, indent string) error { + indentedPrint(w, indent, true, false, "List ID", "%d", l.ID) + indentedPrint(w, indent, false, false, "Title", "%s", l.Title) return nil } @@ -239,6 +276,7 @@ indentedPrint(w, indent, false, false, "Followed-by", "%v", r.FollowedBy) indentedPrint(w, indent, false, false, "Blocking", "%v", r.Blocking) indentedPrint(w, indent, false, false, "Muting", "%v", r.Muting) + indentedPrint(w, indent, false, false, "Muting notifications", "%v", r.MutingNotifications) indentedPrint(w, indent, false, false, "Requested", "%v", r.Requested) return nil } @@ -278,6 +316,9 @@ } indentedPrint(w, indent, false, false, "From", "%s", author) } + if s.Pinned { + indentedPrint(w, indent, false, false, "Pinned", "%v", s.Pinned) + } if s.Visibility == "private" { indentedPrint(w, indent, false, false, "Private", "true") } @@ -313,6 +354,7 @@ } else if a.RemoteURL != nil { indentedPrint(w, indent+p.Indent, false, false, "Remote URL", "%s", *a.RemoteURL) } + indentedPrint(w, indent+p.Indent, false, true, "Description", "%s", a.Description) } return nil }