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
parent
98f591c5e2
commit
ae970802cf
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in New Issue