Skip to content

Commit

Permalink
Add command timeline-tag to search for statuses matching the tag.
Browse files Browse the repository at this point in the history
Since `search` only return the list of tags matching the search, this is
helpful to actually see the statuses for a particular tag.
  • Loading branch information
raff authored and mattn committed Nov 30, 2022
1 parent 98f591c commit ae97080
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/mstdn/cmd_timeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"context"
"errors"
"strings"

"github.com/mattn/go-mastodon"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -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
}
11 changes: 11 additions & 0 deletions cmd/mstdn/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ func makeApp() *cli.App {
Usage: "show timeline direct",
Action: cmdTimelineDirect,
},
{
Name: "timeline-tag",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "local",
Usage: "local tags only",
},
},
Usage: "show tagged timeline",
Action: cmdTimelineHashtag,
},
{
Name: "notification",
Usage: "show notification",
Expand Down

0 comments on commit ae97080

Please sign in to comment.