ref: 8ee08e84e56e321733b64ba7829ebf8c7ab10ee3
parent: 5f003d0c8c4be2dbbac6358d22f99f1d6c24ef2b
author: penny <penny@limitedideas.org>
date: Mon Nov 3 16:46:07 EST 2025
port /cat
--- a/commands.go
+++ b/commands.go
@@ -108,6 +108,8 @@
acc_resolve
// Load user's own most recent post if they have one
want_recent
+ // Set up a templater for us
+ templater
)
type cmdloader struct {@@ -175,6 +177,11 @@
data.account = &hc.recentpost.Account
}
}
+ if flags&templater != 0 && data.status != nil {+ formatter := &StatusFormatter{prefs: hc.preferences, status: data.status, postContext: hc.ctxref, localindex: data.index}+ templater := newStatusTemplateRenderer(formatter)
+ data.templater = templater
+ }
err = data.checkReqs(loader.cmdmap[data.command].flags())
if err != nil {return "", err
@@ -247,6 +254,7 @@
found_index bool
dot_index bool
index string
+ templater *templateRenderer
}
@@ -608,7 +616,6 @@
func (hc *Hellclient) replycmd() cmder { cmd := &basiccmd{}- cmd.hc = hc
cmd.bname = "reply"
cmd.bflags = status
cmd.doer = func(data *cmddata) string {@@ -699,8 +706,21 @@
return cmd
}
+func (hc *Hellclient) catcmd() cmder {+ cmd := &basiccmd{}+ cmd.hc = hc
+ cmd.bname = "cat"
+ cmd.bflags = status | templater
+ cmd.doer = func(data *cmddata) string {+ line, _ := data.templater.render("$index $display_name $username_full $content $media_descriptions\n$detail_line")+ return fmt.Sprint(line)
+ }
+ return cmd
+}
+
func (hc *Hellclient) newCmdArray() []cmder { cmdarray := []cmder{+ hc.catcmd(),
hc.replycmd(),
hc.rmcmd(),
&profilecmd{hc, hc.cmdload},--- a/main.go
+++ b/main.go
@@ -23,7 +23,6 @@
enablePipeHack(rl)
homeMap := hc.homeMap
- debugMap := hc.debugMap
lastindex := ""
recentpost := &hc.recentpost
var lastaccount *mastodon.Account
@@ -75,7 +74,6 @@
postItem, postOK := homeMap[index]
- debugItem := debugMap[index]
//Wether we got a post index or not
foundindex := false
@@ -119,31 +117,6 @@
lastindex = ""
postItem = nil
lastaccount = account
- return
- }
-
- //Contextual commands that need to handle their own requirements
- switch command {- case "public":
- hc.page = &Page{}- localAPI := func(ctx context.Context, pg *mastodon.Pagination) ([]*mastodon.Status, error) {- return hc.client.GetTimelinePublic(ctx, false, pg)
- }
- getter := &BasicStatusGetter{getter: localAPI}- hc.page.loader = &StatusPages{hc: hc, getter: getter}- fmt.Print(hc.page.String())
- hc.pause(true)
- return
- }
-
- //Commands that accept debug indexes
- switch command {- case "examine":
- if foundindex {- hc.PrintObjectProperties(postItem)
- return
- }
- hc.PrintObjectProperties(debugItem)
return
}
formatter := &StatusFormatter{prefs: hc.preferences, status: postItem, postContext: hc.ctxref, localindex: index}--
⑨