PlainPrinter: Display username of a status author
authorMikael Berthe <mikael@lilotux.net>
Thu, 11 May 2017 18:48:22 +0200
changeset 121 10453a1c5698
parent 120 54b6f2a4098b
child 122 6f318b094b78
PlainPrinter: Display username of a status author
printer/plainprinter.go
--- a/printer/plainprinter.go	Thu May 11 18:05:06 2017 +0200
+++ b/printer/plainprinter.go	Thu May 11 18:48:22 2017 +0200
@@ -262,11 +262,19 @@
 
 func (p *PlainPrinter) plainPrintStatus(s *madon.Status, w io.Writer, indent string) error {
 	indentedPrint(w, indent, true, false, "Status ID", "%d", s.ID)
-	indentedPrint(w, indent, false, false, "From", "%s", s.Account.Acct)
+	if s.Account != nil {
+		author := s.Account.Acct
+		if s.Account.DisplayName != "" {
+			author += " (" + s.Account.DisplayName + ")"
+		}
+		indentedPrint(w, indent, false, false, "From", "%s", author)
+	}
 	indentedPrint(w, indent, false, false, "Timestamp", "%v", s.CreatedAt.Local())
 
 	if s.Reblog != nil {
-		indentedPrint(w, indent, false, false, "Reblogged from", "%s", s.Reblog.Account.Username)
+		if s.Reblog.Account != nil {
+			indentedPrint(w, indent, false, false, "Reblogged from", "%s", s.Reblog.Account.Username)
+		}
 		return p.plainPrintStatus(s.Reblog, w, indent+p.Indent)
 	}