15 ) |
15 ) |
16 |
16 |
17 var domainBlocksOpts struct { |
17 var domainBlocksOpts struct { |
18 show, block, unblock bool |
18 show, block, unblock bool |
19 |
19 |
20 limit uint // Limit the results |
20 limit uint // Limit the results |
21 sinceID, maxID int64 // Query boundaries |
21 sinceID, maxID madon.ActivityID // Query boundaries |
22 all bool // Try to fetch all results |
22 all bool // Try to fetch all results |
23 } |
23 } |
24 |
24 |
25 // timelinesCmd represents the timelines command |
25 // timelinesCmd represents the timelines command |
26 var domainBlocksCmd = &cobra.Command{ |
26 var domainBlocksCmd = &cobra.Command{ |
27 Use: "domain-blocks --show|--block|--unblock [DOMAINNAME]", |
27 Use: "domain-blocks --show|--block|--unblock [DOMAINNAME]", |
39 domainBlocksCmd.Flags().BoolVar(&domainBlocksOpts.show, "show", false, "List current user-blocked domains") |
39 domainBlocksCmd.Flags().BoolVar(&domainBlocksOpts.show, "show", false, "List current user-blocked domains") |
40 domainBlocksCmd.Flags().BoolVar(&domainBlocksOpts.block, "block", false, "Block domain") |
40 domainBlocksCmd.Flags().BoolVar(&domainBlocksOpts.block, "block", false, "Block domain") |
41 domainBlocksCmd.Flags().BoolVar(&domainBlocksOpts.unblock, "unblock", false, "Unblock domain") |
41 domainBlocksCmd.Flags().BoolVar(&domainBlocksOpts.unblock, "unblock", false, "Unblock domain") |
42 |
42 |
43 domainBlocksCmd.Flags().UintVarP(&domainBlocksOpts.limit, "limit", "l", 0, "Limit number of results") |
43 domainBlocksCmd.Flags().UintVarP(&domainBlocksOpts.limit, "limit", "l", 0, "Limit number of results") |
44 domainBlocksCmd.Flags().Int64Var(&domainBlocksOpts.sinceID, "since-id", 0, "Request IDs greater than a value") |
44 domainBlocksCmd.Flags().StringVar(&domainBlocksOpts.sinceID, "since-id", "", "Request IDs greater than a value") |
45 domainBlocksCmd.Flags().Int64Var(&domainBlocksOpts.maxID, "max-id", 0, "Request IDs less (or equal) than a value") |
45 domainBlocksCmd.Flags().StringVar(&domainBlocksOpts.maxID, "max-id", "", "Request IDs less (or equal) than a value") |
46 domainBlocksCmd.Flags().BoolVar(&domainBlocksOpts.all, "all", false, "Fetch all results") |
46 domainBlocksCmd.Flags().BoolVar(&domainBlocksOpts.all, "all", false, "Fetch all results") |
47 } |
47 } |
48 |
48 |
49 func domainBlocksRunE(cmd *cobra.Command, args []string) error { |
49 func domainBlocksRunE(cmd *cobra.Command, args []string) error { |
50 opt := domainBlocksOpts |
50 opt := domainBlocksOpts |
69 return errors.New("missing flag: please provide --show, --block or --unblock") |
69 return errors.New("missing flag: please provide --show, --block or --unblock") |
70 } |
70 } |
71 |
71 |
72 // Set up LimitParams |
72 // Set up LimitParams |
73 var limOpts *madon.LimitParams |
73 var limOpts *madon.LimitParams |
74 if opt.all || opt.limit > 0 || opt.sinceID > 0 || opt.maxID > 0 { |
74 if opt.all || opt.limit > 0 || opt.sinceID != "" || opt.maxID != "" { |
75 limOpts = new(madon.LimitParams) |
75 limOpts = new(madon.LimitParams) |
76 limOpts.All = opt.all |
76 limOpts.All = opt.all |
77 } |
77 } |
78 if opt.limit > 0 { |
78 if opt.limit > 0 { |
79 limOpts.Limit = int(opt.limit) |
79 limOpts.Limit = int(opt.limit) |
80 } |
80 } |
81 if opt.maxID > 0 { |
81 if opt.maxID != "" { |
82 limOpts.MaxID = opt.maxID |
82 limOpts.MaxID = opt.maxID |
83 } |
83 } |
84 if opt.sinceID > 0 { |
84 if opt.sinceID != "" { |
85 limOpts.SinceID = opt.sinceID |
85 limOpts.SinceID = opt.sinceID |
86 } |
86 } |
87 |
87 |
88 // Log in |
88 // Log in |
89 if err := madonInit(true); err != nil { |
89 if err := madonInit(true); err != nil { |