cmd/timelines.go
changeset 167 1341bacd01c9
parent 110 57843255fd1a
child 185 564d92b54b00
equal deleted inserted replaced
166:79c0f8db66ff 167:1341bacd01c9
    13 	"github.com/McKael/madon"
    13 	"github.com/McKael/madon"
    14 )
    14 )
    15 
    15 
    16 var timelineOpts struct {
    16 var timelineOpts struct {
    17 	local          bool
    17 	local          bool
    18 	limit          uint
    18 	limit, keep    uint
    19 	sinceID, maxID int64
    19 	sinceID, maxID int64
    20 }
    20 }
    21 
    21 
    22 // timelineCmd represents the timelines command
    22 // timelineCmd represents the timelines command
    23 var timelineCmd = &cobra.Command{
    23 var timelineCmd = &cobra.Command{
    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())