PlainPrinter: Display attachment URLs in statuses
authorMikael Berthe <mikael@lilotux.net>
Mon, 01 May 2017 20:46:14 +0200
changeset 58 5a0cb1e65e65
parent 57 e6ca4d08decd
child 59 ff88978ceb55
PlainPrinter: Display attachment URLs in statuses
printer/plain.go
--- a/printer/plain.go	Mon May 01 12:33:55 2017 +0000
+++ b/printer/plain.go	Mon May 01 20:46:14 2017 +0200
@@ -278,6 +278,18 @@
 		indentedPrint(w, indent, false, false, "Reblogged", "%v", s.Reblogged)
 	}
 	indentedPrint(w, indent, false, false, "URL", "%s", s.URL)
+	// Display minimum details of attachments
+	//return p.PrintObj(s.MediaAttachments, w, indent+p.Indent)
+	for _, a := range s.MediaAttachments {
+		indentedPrint(w, indent+p.Indent, true, false, "Attachment ID", "%d", a.ID)
+		if a.TextURL != "" {
+			indentedPrint(w, indent+p.Indent, true, false, "Text URL", "%s", a.TextURL)
+		} else if a.URL != "" {
+			indentedPrint(w, indent+p.Indent, false, false, "URL", "%s", a.URL)
+		} else {
+			indentedPrint(w, indent+p.Indent, false, false, "Remote URL", "%s", a.RemoteURL)
+		}
+	}
 	return nil
 }