PlainPrinter: Fix attachment output
authorMikael Berthe <mikael@lilotux.net>
Tue, 20 Mar 2018 21:59:16 +0100
changeset 203 71455784278b
parent 202 1c058699177b
child 204 81da8b48bbbc
PlainPrinter: Fix attachment output
printer/plainprinter.go
--- a/printer/plainprinter.go	Tue Mar 20 21:53:57 2018 +0100
+++ b/printer/plainprinter.go	Tue Mar 20 21:59:16 2018 +0100
@@ -190,10 +190,16 @@
 	indentedPrint(w, indent, true, false, "Attachment ID", "%d", a.ID)
 	indentedPrint(w, indent, false, false, "Type", "%s", a.Type)
 	indentedPrint(w, indent, false, false, "Local URL", "%s", a.URL)
-	indentedPrint(w, indent, false, true, "Remote URL", "%s", a.RemoteURL)
+	if a.RemoteURL != nil {
+		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)
+	if a.TextURL != nil {
+		indentedPrint(w, indent, false, true, "Text URL", "%s", *a.TextURL)
+	}
+	if a.Description != nil {
+		indentedPrint(w, indent, false, true, "Description", "%s", *a.Description)
+	}
 	return nil
 }
 
@@ -348,7 +354,9 @@
 		} 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)
+		if a.Description != nil && *a.Description != "" {
+			indentedPrint(w, indent+p.Indent, false, true, "Description", "%s", a.Description)
+		}
 	}
 	return nil
 }