37 |
37 |
38 func init() { |
38 func init() { |
39 RootCmd.AddCommand(timelineCmd) |
39 RootCmd.AddCommand(timelineCmd) |
40 |
40 |
41 timelineCmd.Flags().BoolVar(&timelineOpts.local, "local", false, "Posts from the local instance") |
41 timelineCmd.Flags().BoolVar(&timelineOpts.local, "local", false, "Posts from the local instance") |
42 timelineCmd.Flags().UintVarP(&timelineOpts.limit, "limit", "l", 0, "Limit number of results") |
42 timelineCmd.Flags().UintVarP(&timelineOpts.limit, "limit", "l", 0, "Limit number of API results") |
|
43 timelineCmd.Flags().UintVarP(&timelineOpts.keep, "keep", "k", 0, "Limit number of results") |
43 timelineCmd.PersistentFlags().Int64Var(&timelineOpts.sinceID, "since-id", 0, "Request IDs greater than a value") |
44 timelineCmd.PersistentFlags().Int64Var(&timelineOpts.sinceID, "since-id", 0, "Request IDs greater than a value") |
44 timelineCmd.PersistentFlags().Int64Var(&timelineOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value") |
45 timelineCmd.PersistentFlags().Int64Var(&timelineOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value") |
45 } |
46 } |
46 |
47 |
47 func timelineRunE(cmd *cobra.Command, args []string) error { |
48 func timelineRunE(cmd *cobra.Command, args []string) error { |
76 if err != nil { |
77 if err != nil { |
77 errPrint("Error: %s", err.Error()) |
78 errPrint("Error: %s", err.Error()) |
78 os.Exit(1) |
79 os.Exit(1) |
79 } |
80 } |
80 |
81 |
81 if opt.limit > 0 && len(sl) > int(opt.limit) { |
82 if opt.keep > 0 && len(sl) > int(opt.keep) { |
82 sl = sl[:opt.limit] |
83 sl = sl[:opt.keep] |
83 } |
84 } |
84 |
85 |
85 p, err := getPrinter() |
86 p, err := getPrinter() |
86 if err != nil { |
87 if err != nil { |
87 errPrint("Error: %s", err.Error()) |
88 errPrint("Error: %s", err.Error()) |