2017-04-15 14:52:11 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-04-17 04:10:29 +02:00
|
|
|
"context"
|
2017-04-15 14:52:11 +02:00
|
|
|
|
|
|
|
"github.com/mattn/go-mastodon"
|
2022-11-27 05:24:42 +01:00
|
|
|
"github.com/urfave/cli/v2"
|
2017-04-15 14:52:11 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func cmdTimeline(c *cli.Context) error {
|
|
|
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
2017-04-19 13:52:14 +02:00
|
|
|
config := c.App.Metadata["config"].(*mastodon.Config)
|
2017-05-06 16:49:46 +02:00
|
|
|
timeline, err := client.GetTimelineHome(context.Background(), nil)
|
2017-04-15 14:52:11 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-04-19 16:21:19 +02:00
|
|
|
s := newScreen(config)
|
2017-04-15 14:52:11 +02:00
|
|
|
for i := len(timeline) - 1; i >= 0; i-- {
|
2017-04-19 16:21:19 +02:00
|
|
|
s.displayStatus(c.App.Writer, timeline[i])
|
2017-04-15 14:52:11 +02:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2019-06-21 18:44:24 +02:00
|
|
|
|
|
|
|
func cmdTimelineHome(c *cli.Context) error {
|
|
|
|
return cmdTimeline(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func cmdTimelinePublic(c *cli.Context) error {
|
|
|
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
|
|
|
config := c.App.Metadata["config"].(*mastodon.Config)
|
|
|
|
timeline, err := client.GetTimelinePublic(context.Background(), false, 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
|
|
|
|
}
|
|
|
|
|
|
|
|
func cmdTimelineLocal(c *cli.Context) error {
|
|
|
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
|
|
|
config := c.App.Metadata["config"].(*mastodon.Config)
|
|
|
|
timeline, err := client.GetTimelinePublic(context.Background(), true, 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
|
|
|
|
}
|
|
|
|
|
|
|
|
func cmdTimelineDirect(c *cli.Context) error {
|
|
|
|
client := c.App.Metadata["client"].(*mastodon.Client)
|
|
|
|
config := c.App.Metadata["config"].(*mastodon.Config)
|
|
|
|
timeline, err := client.GetTimelineDirect(context.Background(), 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
|
|
|
|
}
|