15 ) |
15 ) |
16 |
16 |
17 var timelineOpts struct { |
17 var timelineOpts struct { |
18 local, onlyMedia bool |
18 local, onlyMedia bool |
19 limit, keep uint |
19 limit, keep uint |
20 sinceID, maxID int64 |
20 sinceID, maxID madon.ActivityID |
21 } |
21 } |
22 |
22 |
23 // timelineCmd represents the timelines command |
23 // timelineCmd represents the timelines command |
24 var timelineCmd = &cobra.Command{ |
24 var timelineCmd = &cobra.Command{ |
25 Use: "timeline [home|public|direct|:HASHTAG|!list_id] [--local]", |
25 Use: "timeline [home|public|direct|:HASHTAG|!list_id] [--local]", |
45 |
45 |
46 timelineCmd.Flags().BoolVar(&timelineOpts.local, "local", false, "Posts from the local instance") |
46 timelineCmd.Flags().BoolVar(&timelineOpts.local, "local", false, "Posts from the local instance") |
47 timelineCmd.Flags().BoolVar(&timelineOpts.onlyMedia, "only-media", false, "Only statuses with media attachments") |
47 timelineCmd.Flags().BoolVar(&timelineOpts.onlyMedia, "only-media", false, "Only statuses with media attachments") |
48 timelineCmd.Flags().UintVarP(&timelineOpts.limit, "limit", "l", 0, "Limit number of API results") |
48 timelineCmd.Flags().UintVarP(&timelineOpts.limit, "limit", "l", 0, "Limit number of API results") |
49 timelineCmd.Flags().UintVarP(&timelineOpts.keep, "keep", "k", 0, "Limit number of results") |
49 timelineCmd.Flags().UintVarP(&timelineOpts.keep, "keep", "k", 0, "Limit number of results") |
50 timelineCmd.PersistentFlags().Int64Var(&timelineOpts.sinceID, "since-id", 0, "Request IDs greater than a value") |
50 timelineCmd.PersistentFlags().StringVar(&timelineOpts.sinceID, "since-id", "", "Request IDs greater than a value") |
51 timelineCmd.PersistentFlags().Int64Var(&timelineOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value") |
51 timelineCmd.PersistentFlags().StringVar(&timelineOpts.maxID, "max-id", "", "Request IDs less (or equal) than a value") |
52 } |
52 } |
53 |
53 |
54 func timelineRunE(cmd *cobra.Command, args []string) error { |
54 func timelineRunE(cmd *cobra.Command, args []string) error { |
55 opt := timelineOpts |
55 opt := timelineOpts |
56 var limOpts *madon.LimitParams |
56 var limOpts *madon.LimitParams |
57 |
57 |
58 if opt.limit > 0 || opt.sinceID > 0 || opt.maxID > 0 { |
58 if opt.limit > 0 || opt.sinceID != "" || opt.maxID != "" { |
59 limOpts = new(madon.LimitParams) |
59 limOpts = new(madon.LimitParams) |
60 } |
60 } |
61 |
61 |
62 if opt.limit > 0 { |
62 if opt.limit > 0 { |
63 limOpts.Limit = int(opt.limit) |
63 limOpts.Limit = int(opt.limit) |
64 } |
64 } |
65 if opt.maxID > 0 { |
65 if opt.maxID != "" { |
66 limOpts.MaxID = opt.maxID |
66 limOpts.MaxID = opt.maxID |
67 } |
67 } |
68 if opt.sinceID > 0 { |
68 if opt.sinceID != "" { |
69 limOpts.SinceID = opt.sinceID |
69 limOpts.SinceID = opt.sinceID |
70 } |
70 } |
71 |
71 |
72 tl := "home" |
72 tl := "home" |
73 if len(args) > 0 { |
73 if len(args) > 0 { |