Add command timeline-tag to search for statuses matching the tag.

Since `search` only return the list of tags matching the search, this is
helpful to actually see the statuses for a particular tag.
This commit is contained in:
Raffaele Sena 2022-11-22 11:23:26 -08:00 committed by mattn
parent 98f591c5e2
commit ae970802cf
2 changed files with 33 additions and 0 deletions

View file

@ -2,6 +2,8 @@ package main
import (
"context"
"errors"
"strings"
"github.com/mattn/go-mastodon"
"github.com/urfave/cli/v2"
@ -66,3 +68,23 @@ func cmdTimelineDirect(c *cli.Context) error {
}
return nil
}
func cmdTimelineHashtag(c *cli.Context) error {
if !c.Args().Present() {
return errors.New("arguments required")
}
local := c.Bool("local")
tag := strings.TrimLeft(argstr(c), "#")
client := c.App.Metadata["client"].(*mastodon.Client)
config := c.App.Metadata["config"].(*mastodon.Config)
timeline, err := client.GetTimelineHashtag(context.Background(), tag, local, nil)
if err != nil {
return err
}
s := newScreen(config)
for i := len(timeline) - 1; i >= 0; i-- {
s.displayStatus(c.App.Writer, timeline[i])
}
return nil
}