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.
pull/166/head
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 ( import (
"context" "context"
"errors"
"strings"
"github.com/mattn/go-mastodon" "github.com/mattn/go-mastodon"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
@ -66,3 +68,23 @@ func cmdTimelineDirect(c *cli.Context) error {
} }
return nil 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
}

View File

@ -255,6 +255,17 @@ func makeApp() *cli.App {
Usage: "show timeline direct", Usage: "show timeline direct",
Action: cmdTimelineDirect, Action: cmdTimelineDirect,
}, },
{
Name: "timeline-tag",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "local",
Usage: "local tags only",
},
},
Usage: "show tagged timeline",
Action: cmdTimelineHashtag,
},
{ {
Name: "notification", Name: "notification",
Usage: "show notification", Usage: "show notification",