cmd/timelines.go
changeset 20 b0ccc09f07a2
parent 13 f862af8faf17
child 22 5778b09bc6fe
--- a/cmd/timelines.go	Fri Apr 28 13:31:40 2017 +0200
+++ b/cmd/timelines.go	Fri Apr 28 15:39:32 2017 +0200
@@ -7,6 +7,8 @@
 
 import (
 	"github.com/spf13/cobra"
+
+	"github.com/McKael/madon"
 )
 
 var timelineOpts struct {
@@ -39,6 +41,12 @@
 
 func timelineRunE(cmd *cobra.Command, args []string) error {
 	opt := timelineOpts
+	var limOpts *madon.LimitParams
+
+	if opt.limit > 0 {
+		limOpts = new(madon.LimitParams)
+		limOpts.Limit = int(opt.limit)
+	}
 
 	tl := "home"
 	if len(args) > 0 {
@@ -50,13 +58,13 @@
 		return err
 	}
 
-	sl, err := gClient.GetTimelines(tl, opt.local)
+	sl, err := gClient.GetTimelines(tl, opt.local, limOpts)
 	if err != nil {
 		errPrint("Error: %s", err.Error())
 		return nil
 	}
 
-	if opt.limit > 0 {
+	if opt.limit > 0 && len(sl) > int(opt.limit) {
 		sl = sl[:opt.limit]
 	}