go-mastodon/cmd/mstdn/cmd_timeline.go

27 lines
553 B
Go
Raw Normal View History

2017-04-15 14:52:11 +02:00
package main
import (
"context"
2017-04-15 14:52:11 +02:00
"fmt"
"github.com/fatih/color"
"github.com/mattn/go-mastodon"
"github.com/urfave/cli"
)
func cmdTimeline(c *cli.Context) error {
client := c.App.Metadata["client"].(*mastodon.Client)
timeline, err := client.GetTimelineHome(context.Background())
2017-04-15 14:52:11 +02:00
if err != nil {
return err
}
for i := len(timeline) - 1; i >= 0; i-- {
t := timeline[i]
color.Set(color.FgHiRed)
2017-04-16 16:04:31 +02:00
fmt.Fprintln(c.App.Writer, t.Account.Username)
2017-04-15 14:52:11 +02:00
color.Set(color.Reset)
2017-04-16 16:04:31 +02:00
fmt.Fprintln(c.App.Writer, textContent(t.Content))
2017-04-15 14:52:11 +02:00
}
return nil
}