equal
deleted
inserted
replaced
9 "github.com/spf13/cobra" |
9 "github.com/spf13/cobra" |
10 ) |
10 ) |
11 |
11 |
12 var timelineOpts struct { |
12 var timelineOpts struct { |
13 local bool |
13 local bool |
|
14 limit uint |
14 } |
15 } |
15 |
16 |
16 // timelineCmd represents the timelines command |
17 // timelineCmd represents the timelines command |
17 var timelineCmd = &cobra.Command{ |
18 var timelineCmd = &cobra.Command{ |
18 Use: "timeline [home|public|:HASHTAG] [--local]", |
19 Use: "timeline [home|public|:HASHTAG] [--local]", |
31 |
32 |
32 func init() { |
33 func init() { |
33 RootCmd.AddCommand(timelineCmd) |
34 RootCmd.AddCommand(timelineCmd) |
34 |
35 |
35 timelineCmd.Flags().BoolVar(&timelineOpts.local, "local", false, "Posts from the local instance") |
36 timelineCmd.Flags().BoolVar(&timelineOpts.local, "local", false, "Posts from the local instance") |
|
37 timelineCmd.Flags().UintVarP(&timelineOpts.limit, "limit", "l", 0, "Limit number of results") |
36 } |
38 } |
37 |
39 |
38 func timelineRunE(cmd *cobra.Command, args []string) error { |
40 func timelineRunE(cmd *cobra.Command, args []string) error { |
39 opt := timelineOpts |
41 opt := timelineOpts |
40 |
42 |
52 if err != nil { |
54 if err != nil { |
53 errPrint("Error: %s", err.Error()) |
55 errPrint("Error: %s", err.Error()) |
54 return nil |
56 return nil |
55 } |
57 } |
56 |
58 |
|
59 if opt.limit > 0 { |
|
60 sl = sl[:opt.limit] |
|
61 } |
|
62 |
57 p, err := getPrinter() |
63 p, err := getPrinter() |
58 if err != nil { |
64 if err != nil { |
59 return err |
65 return err |
60 } |
66 } |
61 return p.PrintObj(sl, nil, "") |
67 return p.PrintObj(sl, nil, "") |