48 accountsCmd.AddCommand(notificationsCmd) |
48 accountsCmd.AddCommand(notificationsCmd) |
49 |
49 |
50 notificationsCmd.Flags().BoolVar(¬ificationsOpts.list, "list", false, "List all current notifications") |
50 notificationsCmd.Flags().BoolVar(¬ificationsOpts.list, "list", false, "List all current notifications") |
51 notificationsCmd.Flags().BoolVar(¬ificationsOpts.clear, "clear", false, "Clear all current notifications") |
51 notificationsCmd.Flags().BoolVar(¬ificationsOpts.clear, "clear", false, "Clear all current notifications") |
52 notificationsCmd.Flags().BoolVar(¬ificationsOpts.dismiss, "dismiss", false, "Delete a notification") |
52 notificationsCmd.Flags().BoolVar(¬ificationsOpts.dismiss, "dismiss", false, "Delete a notification") |
53 notificationsCmd.Flags().Int64Var(¬ificationsOpts.notifID, "notification-id", 0, "Get a notification") |
53 notificationsCmd.Flags().StringVar(¬ificationsOpts.notifID, "notification-id", "", "Get a notification") |
54 notificationsCmd.Flags().StringVar(¬ificationsOpts.types, "notification-types", "", "Filter notifications (mention, favourite, reblog, follow)") |
54 notificationsCmd.Flags().StringVar(¬ificationsOpts.types, "notification-types", "", "Filter notifications (mention, favourite, reblog, follow)") |
55 notificationsCmd.Flags().StringVar(¬ificationsOpts.excludeTypes, "exclude-types", "", "Exclude notifications types (mention, favourite, reblog, follow)") |
55 notificationsCmd.Flags().StringVar(¬ificationsOpts.excludeTypes, "exclude-types", "", "Exclude notifications types (mention, favourite, reblog, follow)") |
56 } |
56 } |
57 |
57 |
58 func notificationRunE(cmd *cobra.Command, args []string) error { |
58 func notificationRunE(cmd *cobra.Command, args []string) error { |
59 opt := notificationsOpts |
59 opt := notificationsOpts |
60 |
60 |
61 if !opt.list && !opt.clear && opt.notifID < 1 { |
61 if !opt.list && !opt.clear && opt.notifID == "" { |
62 return errors.New("missing parameters") |
62 return errors.New("missing parameters") |
63 } |
63 } |
64 |
64 |
65 if err := madonInit(true); err != nil { |
65 if err := madonInit(true); err != nil { |
66 return err |
66 return err |
67 } |
67 } |
68 |
68 |
69 var limOpts *madon.LimitParams |
69 var limOpts *madon.LimitParams |
70 if accountsOpts.all || accountsOpts.limit > 0 || accountsOpts.sinceID > 0 || accountsOpts.maxID > 0 { |
70 if accountsOpts.all || accountsOpts.limit > 0 || accountsOpts.sinceID != "" || accountsOpts.maxID != "" { |
71 limOpts = new(madon.LimitParams) |
71 limOpts = new(madon.LimitParams) |
72 limOpts.All = accountsOpts.all |
72 limOpts.All = accountsOpts.all |
73 } |
73 } |
74 |
74 |
75 if accountsOpts.limit > 0 { |
75 if accountsOpts.limit > 0 { |
76 limOpts.Limit = int(accountsOpts.limit) |
76 limOpts.Limit = int(accountsOpts.limit) |
77 } |
77 } |
78 if accountsOpts.maxID > 0 { |
78 if accountsOpts.maxID != "" { |
79 limOpts.MaxID = int64(accountsOpts.maxID) |
79 limOpts.MaxID = accountsOpts.maxID |
80 } |
80 } |
81 if accountsOpts.sinceID > 0 { |
81 if accountsOpts.sinceID != "" { |
82 limOpts.SinceID = int64(accountsOpts.sinceID) |
82 limOpts.SinceID = accountsOpts.sinceID |
83 } |
83 } |
84 |
84 |
85 var filterMap *map[string]bool |
85 var filterMap *map[string]bool |
86 if opt.types != "" { |
86 if opt.types != "" { |
87 var err error |
87 var err error |