ref: 0c3c92606846c5e1277b980a5d7903c1f1143345
parent: 488086fe4bf6f95845f02b6a4154eb42c0196683
author: penny <penny@limitedideas.org>
date: Sun Oct 5 22:41:36 EDT 2025
use templates for bookmark commands
--- a/main.go
+++ b/main.go
@@ -247,6 +247,8 @@
hc.PrintObjectProperties(debugItem)
return
}
+ formatter := &StatusFormatter{hc: hc, status: postItem, postContext: hc.ctxref}+ templater := newStatusTemplateRenderer(formatter)
//Commands require status indexes
switch command {@@ -258,8 +260,6 @@
if index == "" {index = lastindex
}
- formatter := &StatusFormatter{hc: hc, status: postItem, postContext: hc.ctxref}- templater := newStatusTemplateRenderer(formatter)
line, _ := templater.render(fmt.Sprintf("%s> $username $content $media_descriptions\n$detail_line", index))fmt.Print(line)
return
@@ -276,7 +276,8 @@
if err != nil {printMastodonErr(err)
} else {- fmt.Println(hc.formatBookmark(postItem, arguments))
+ line, _ := templater.render(fmt.Sprintf("Bookmarked: %s> $username $content $media_descriptions\n", index))+ fmt.Print(line)
}
return
case "unmark":
@@ -289,7 +290,8 @@
if err != nil {printMastodonErr(err)
} else {- fmt.Println(hc.formatUnbookmark(postItem, arguments))
+ line, _ := templater.render(fmt.Sprintf("Unbookmarked: %s> $username $content $media_descriptions\n", index))+ fmt.Print(line)
}
return
case "open":
--- a/mastodon.go
+++ b/mastodon.go
@@ -188,16 +188,6 @@
return hc.formatStatusDetailed(post, "", favString)
}
-func (hc *Hellclient) formatBookmark(post *mastodon.Status, index string) string {- favString := fmt.Sprintf("Bookmarked: %s", index)- return hc.formatStatusDetailed(post, "", favString)
-}
-
-func (hc *Hellclient) formatUnbookmark(post *mastodon.Status, index string) string {- favString := fmt.Sprintf("Unbookmarked: %s", index)- return hc.formatStatusDetailed(post, "", favString)
-}
-
func (hc *Hellclient) formatStatusDetailed(post *mastodon.Status, index string, prefix string) string {renderedPost, plaintexts := hc.renderStatus(post.Content, index)
--
⑨