summary refs log tree commit diff
path: root/Completion/Unix/Command/_transmission
blob: 8a4bebec37e2f8588510fa57cc4c9924559fe452 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
#compdef transmission-remote

# arrays of options

# `general_options`: *options* which can be used for any action
local exclusive_auth_options='(-n --auth -ne --authenv -N --netrc)'
local general_options=(
  {-d,--debug}'[enable debugging mode]'
  $exclusive_auth_options{-n-,--auth=}'[set the username and password for authentication]:username\:password: '
  $exclusive_auth_options{-ne,--authenv}'[set the authentication information from the TR_AUTH environment variable]'
  $exclusive_auth_options{-N-,--netrc=}'[set the authentication information from a netrc file]:file:_files'
  '--find[tell Transmission where to look for the current torrents'"'"' data]'
)
# `general_actions`: *actions* that can be specified when a specific set of torrents is either specified or either not
local general_actions=(
  '(- :)'{-gsr,--global-seedratio}'[all torrents, unless overridden by a per-torrent setting, should seed until a specific ratio]:ratio:{_message "ratio in kB/sec"}'
  '(- :)'{-GSR,--no-global-seedratio}'[all torrents, unless overridden by a per-torrent setting, should seed regardless of ratio]'
  '(- :)'{-pr,--peers}'[set the maximum number of peers]:number: '
  '(- :)'{-d-,--downlimit=}'[limit the maximum download speed to limit kB/s]:limit:{_message "limit in kB/sec"}'
  '(- :)'{-D,--no-downlimit}'[disable download speed limits]'
)
# `global_only_actions`: *actions* that can be specified only when no specific torrent is specified
local global_only_actions=(
  '(- :)'{-as,--alt-speed}'[use the alternate Limits]'
  '(- :)'{-AS,--not-alt-speed}'[don'"'"'t use the alternate Limits]'
  '(- :)'{-asd,--alt-speed-downlimit}'[limit the alternate download speed to limit kilobytes per second]'
  '(- :)'{-asu,--alt-speed-uplimit}'[limit the alternate upload speed to limit kilobytes per second]'
  '(- :)'{-asc,--alt-speed-scheduler}'[use the scheduled on/off times]'
  '(- :)'{-asc,--not-alt-speed-scheduler}'[don'"'"'t use the scheduled on/off times]'
  '(- :)--alt-speed-time-begin[time to start using the alt speed limits]:hhmm:_transmission-remote_time'
  '(- :)--alt-speed-time-end[time to stop using the alt speed limits]:hhmm:_transmission-remote_time'
  '(- :)--alt-speed-days[set the number of days on which to enable the speed scheduler]:days:_transmission-remote_days'
  '(- :)--torrent-done-script[specify a file to run each time a torrent finishes]:script:_files'
  '(- :)--no-torrent-done-script[don'"'"'t run any script when a torrent finishes]'
  '(- :)'{-e-,--cache=}'[set the session'"'"'s maximum memory cache size in MiB]:size (MiB):'
  '(- :)'{-er,--encryption-required}'[encrypt all peer connections]'
  '(- :)'{-ep,--encryption-preferred}'[prefer encrypted peer connections]'
  '(- :)'{-et,--encryption-tolerated}'[prefer unencrypted peer connections]'
  '(- :)'{-h,--help}'[print command-line option descriptions]'
  '(- :)--exit[tell the Transmission to initiate a shutdown]'
  '(- :)'{-V,--version}'[show version number and exit]'
  {-t,--torrent=}'[set the current torrent(s) for use by subsequent options]:torrent:_transmission-remote_torrent'
  '(- :)'{-si,--session-info}'[list session information from the server]'
  '(- :)'{-st,--session-stats}'[list statistical information from the server]'
  {-a-,--add=}'[add torrents to transmission]:filename\|url:_transmission-remote_add'
  '(- :)'{-l,--list}'[list all torrents]'
  '(- :)'{-p,--port}'[set the port for use when listening for incoming peer connections]:port:'
  '(- :)--start-paused[start added torrents paused]'
  '(- :)--no-start-paused[start added torrents unpaused]'
  '(- :)'{-m,--portmap}'[enable portmapping via NAT-PMP or UPnP]'
  '(- :)'{-M,--no-portmap}'[disable portmapping]'
  '(- :)'{-o,--dht}'[enable distributed hash table]'
  '(- :)'{-O,--no-dht}'[disable distributed hash table]'
  '(- :)'{-u,--uplimit}'[limit the maximum upload speed to limit kB/s]:limit:{_message "limit in kB/sec"}'
  '(- :)'{-U,--no-uplimit}'[disable upload speed limits]'
  '(- :)--utp[enable uTP for peer connections]'
  '(- :)--no-utp[disable uTP for peer connections]'
  '(- :)'{-x,--pex}'[enable peer exchange (PEX)]'
  '(- :)'{-X,--no-pex}'[disable peer exchange (PEX)]'
  '(- :)'{-y,--lss}'[enable local peer discovery (LPD)]'
  '(- :)'{-Y,--no-lss}'[disable local peer discovery (LPD)]'
  '(- :)'{-pi,--peer-info}"[list the current torrent's connected peers]"
  "(- :)--blocklist-update[update blocklist from URL specified in remote client's settings with blocklist-url key]"
  '*:host\:port:_hosts'
)
# `torrent_add_options`: *options* that can be used only when *adding* a torrent
local torrent_add_options=(
  '(-C --no-incomplete-dir)'{-c-,--incomplete-dir=}'[when adding new torrents, store their contents in directory until the torrent is done]:dir:{_files -/}'
  '(-c --incomplete-dir)'{-C,--no-incomplete-dir}'[don'"'"'t store incomplete torrents in a different directory]'
  {-w-,--download-dir=}'[when used in conjunction with --add, set the new torrent'"'"'s download folder]:dir:{_files -/}'
)
# `torrent_action_only_actions`: *actions* that can be specified only when explicitly selecting a specific set of torrents
local torrent_action_only_actions=(
  {-f,--files}'[get a file list for the current torrent(s)]'
  {-g,--get}'[mark file(s) for download]:torrent_file:_transmission-remote_torrent_get'
  {-G,--no-get}'[mark file(s) for not downloading]:torrent_file:_transmission-remote_torrent_no_get'
  {-i,--info}'[show details of the current torrent(s)]'
  {-if,--info-files}'[list the specified torrent'"'"'s files]'
  {-ip,--info-peers}'[list the specified torrent'"'"'s peers]'
  {-ic,--info-pieces}'[list the specified torrent'"'"'s pieces]'
  {-it,--info-trackers}'[list the specified torrent'"'"'s trackers]'
  '--trash-torrent[delete torrents after adding]'
  '--no-trash-torrent[do not delete torrents after adding]'
  {-td-,--tracker-add=}'[add a tracker to a torrent]:tracker:_urls'
  {-tr-,--tracker-remove=}'[remove a tracker from a torrent]:tracker_id:_transmission-remote_torrent_tracker_id'
  {-s,--start}'[start the current torrent(s)]'
  {-S,--stop}'[stop the current torrent(s) from downloading or seeding]'
  {-r,--remove}'[remove the current torrent(s) without deleting the downloaded data]'
  {-rad,--remove-and-delete}'[remove the current torrent(s) and delete the downloaded data]'
  '--reannounce[reannounce the current torrent(s)]'
  '--move[move the current torrents'"'"' data from their current locations to the specified directory]:{_files -/}'
  {-sr-,--seedratio=}'[let the current torrent(s) seed until a specific ratio]:ratio:{_message "ratio in kB/sec"}'
  {-SR,--no-seedratio}'[let the current torrent(s) use the global seedratio settings]'
  {-hl,--honor-session}'[make the current torrent(s) honor the session limits]'
  {-HL,--no-honor-session}'[make the current torrent(s) not honor the session limits]'
  {-Bh,--bandwidth-high}'[give this torrent first chance at available bandwidth]'
  {-Bn,--bandwidth-normal}'[give this torrent the bandwidth left over by high priority torrents]'
  {-Bl,--bandwidth-low}'[give this torrent the bandwidth left over by high and normal priority torrents]'
  {-ph,--priority-high}'[try to download the specified file(s) first]:torrent_file:_transmission-remote_torrent_priority_not_high'
  {-pn,--priority-normal}'[try to download the specified files normally.]:torrent_file:_transmission-remote_torrent_priority_not_normal'
  {-pl,--priority-low}'[try to download the specified files last]:torrent_file:_transmission-remote_torrent_priority_not_low'
  {-v,--verify}'[verify the current torrent(s)]'
)

# helper functions

# complete argument specified after global only action: `--alt-speed-time-begin`
# completes time in HHMM format
(( $+functions[_transmission-remote_time] )) ||
_transmission-remote_time(){
  _message "time in format HHMS"
}
# complete argument specified after global only action: `--alt-speed-days`
# completes days in a list such as "2,4-6".
(( $+functions[_transmission-remote_days] )) ||
_transmission-remote_days(){
  _values -s , -S '-' days {1..7}
}
# complete argument specified after global only action: `--add`
(( $+functions[_transmission-remote_add] )) ||
_transmission-remote_add(){
_alternative \
    'args:torrent:_files -g ".torrent"' \
    'args:url:_urls'
}
# complete torrents
(( $+functions[_transmission-remote_torrent] )) ||
_transmission-remote_torrent(){
  local authentication_args
  for k in '--auth' '--netrc'; do
    authentication_args="${opt_args[${k}]}"
    if ! [[ -z "${authentication_args}" ]]; then
      authentication_args="$k"="${authentication_args}"
      break
    fi
  done
  if [[ -z "${authentication_args}" ]]; then
    for k in '-n' '-N'; do
      authentication_args="${opt_args[${k}]}"
      if ! [[ -z "${authentication_args}" ]]; then
        authentication_args="$k""${authentication_args}"
        break
      fi
    done
  fi
  if [[ -z "${authentication_args}" ]]; then
    for k in '--authenv' '-ne' '--netrc' '-N'; do
      if [[ ${+opt_args[$k]} == "1" ]]; then
        authentication_args="$k"
        break
      fi
    done
  fi
  local torrents_list_lines=(${(f)"$(transmission-remote "${authentication_args}" --list 2> /dev/null)"})
  local -a parts
  local -a torrents_ids torrents_names
  # While iterating through every line in the output above, we don't need the
  # first and last line which are just a header and summary
  for (( t = 2; t < ${#torrents_list_lines[@]} - 1; ++t )); do
    parts=(${(@s. .)torrents_list_lines[$t]})
    torrents_ids+=("${parts[1]}")
    torrents_names+=("${parts[10,${#parts[@]}]}")
  done
  _describe -t torrents torrent torrents_names torrents_ids
}
# complete action specified after *--torrent*: `--get`
(( $+functions[_transmission-remote_torrent_get] )) ||
_transmission-remote_torrent_get(){
  local authentication_args
  for k in '--auth' '--netrc'; do
    authentication_args="${opt_args[${k}]}"
    if ! [[ -z "${authentication_args}" ]]; then
      authentication_args="$k"="${authentication_args}"
      break
    fi
  done
  if [[ -z "${authentication_args}" ]]; then
    for k in '-n' '-N'; do
      authentication_args="${opt_args[${k}]}"
      if ! [[ -z "${authentication_args}" ]]; then
        authentication_args="$k""${authentication_args}"
        break
      fi
    done
  fi
  if [[ -z "${authentication_args}" ]]; then
    for k in '--authenv' '-ne' '--netrc' '-N'; do
      if [[ ${+opt_args[$k]} == "1" ]]; then
        authentication_args="$k"
        break
      fi
    done
  fi
  local selected_torrent
  for k in '-t' '--torrent'; do
    if [[ ! -z ${opt_args[$k]} ]]; then
      selected_torrent="${opt_args[$k]}"
    fi
  done
  if [[ -z "${selected_torrent}" ]]; then
    _message -r "no torrent was selected on the command line enabling completion of files"
    return
  fi
  local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"})
  local -a parts
  local -a files
  local torrent_name
  for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do
    parts=(${(@s. .)files_info_lines[$f]})
    torrent_name="${parts[7,${#parts[@]}]%/*}"
    if [[ ${parts[4]} == "No" ]]; then
      files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"])
    fi
  done
  if [[ -z "${files}" ]]; then
    _message -r "No files are marked for not downloading in torrent ${torrent_name}"
    return
  fi
  _values -s , -S '-' "files from ${torrent_name}" "${files[@]}"
}
# complete action specified after *--torrent*: `--no-get`
(( $+functions[_transmission-remote_torrent_no_get] )) ||
_transmission-remote_torrent_no_get(){
  local authentication_args
  for k in '--auth' '--netrc'; do
    authentication_args="${opt_args[${k}]}"
    if ! [[ -z "${authentication_args}" ]]; then
      authentication_args="$k"="${authentication_args}"
      break
    fi
  done
  if [[ -z "${authentication_args}" ]]; then
    for k in '-n' '-N'; do
      authentication_args="${opt_args[${k}]}"
      if ! [[ -z "${authentication_args}" ]]; then
        authentication_args="$k""${authentication_args}"
        break
      fi
    done
  fi
  if [[ -z "${authentication_args}" ]]; then
    for k in '--authenv' '-ne' '--netrc' '-N'; do
      if [[ ${+opt_args[$k]} == "1" ]]; then
        authentication_args="$k"
        break
      fi
    done
  fi
  local selected_torrent
  for k in '-t' '--torrent'; do
    if [[ ! -z ${opt_args[$k]} ]]; then
      selected_torrent="${opt_args[$k]}"
    fi
  done
  if [[ -z "${selected_torrent}" ]]; then
    _message -r "no torrent was selected on the command line enabling completion of files"
    return
  fi
  local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"})
  local -a parts
  local -a files
  local torrent_name
  for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do
    parts=(${(@s. .)files_info_lines[$f]})
    torrent_name="${parts[7,${#parts[@]}]%/*}"
    if [[ ${parts[4]} == "Yes" ]]; then
      files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"])
    fi
  done
  if [[ -z "${files}" ]]; then
    _message -r "No files are marked for downloading in torrent ${torrent_name}"
    return
  fi
  _values -s , -S '-' "files from ${torrent_name}" "${files[@]}"
}
# complete action specified after *--torrent*: `--priority-low` or `--priority-normal`
(( $+functions[_transmission-remote_torrent_priority_not_high] )) ||
_transmission-remote_torrent_priority_not_high(){
  local authentication_args
  for k in '--auth' '--netrc'; do
    authentication_args="${opt_args[${k}]}"
    if ! [[ -z "${authentication_args}" ]]; then
      authentication_args="$k"="${authentication_args}"
      break
    fi
  done
  if [[ -z "${authentication_args}" ]]; then
    for k in '-n' '-N'; do
      authentication_args="${opt_args[${k}]}"
      if ! [[ -z "${authentication_args}" ]]; then
        authentication_args="$k""${authentication_args}"
        break
      fi
    done
  fi
  if [[ -z "${authentication_args}" ]]; then
    for k in '--authenv' '-ne' '--netrc' '-N'; do
      if [[ ${+opt_args[$k]} == "1" ]]; then
        authentication_args="$k"
        break
      fi
    done
  fi
  local selected_torrent
  for k in '-t' '--torrent'; do
    if [[ ! -z ${opt_args[$k]} ]]; then
      selected_torrent="${opt_args[$k]}"
    fi
  done
  if [[ -z "${selected_torrent}" ]]; then
    _message -r "no torrent was selected on the command line enabling completion of files"
    return
  fi
  local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"})
  local -a parts
  local -a files
  local torrent_name
  for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do
    parts=(${(@s. .)files_info_lines[$f]})
    torrent_name="${parts[7,${#parts[@]}]%/*}"
    if [[ ${parts[3]} != "High" ]]; then
      files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"])
    fi
  done
  if [[ -z "${files}" ]]; then
    _message -r "No files are marked with non-high priority in torrent ${torrent_name}"
    return
  fi
  _values -s , -S '-' "files from ${torrent_name}" "${files[@]}"
}
# complete action specified after *--torrent*: `--priority-low` or `--priority-high`
(( $+functions[_transmission-remote_torrent_priority_not_normal] )) ||
_transmission-remote_torrent_priority_not_normal(){
  local authentication_args
  for k in '--auth' '--netrc'; do
    authentication_args="${opt_args[${k}]}"
    if ! [[ -z "${authentication_args}" ]]; then
      authentication_args="$k"="${authentication_args}"
      break
    fi
  done
  if [[ -z "${authentication_args}" ]]; then
    for k in '-n' '-N'; do
      authentication_args="${opt_args[${k}]}"
      if ! [[ -z "${authentication_args}" ]]; then
        authentication_args="$k""${authentication_args}"
        break
      fi
    done
  fi
  if [[ -z "${authentication_args}" ]]; then
    for k in '--authenv' '-ne' '--netrc' '-N'; do
      if [[ ${+opt_args[$k]} == "1" ]]; then
        authentication_args="$k"
        break
      fi
    done
  fi
  local selected_torrent
  for k in '-t' '--torrent'; do
    if [[ ! -z ${opt_args[$k]} ]]; then
      selected_torrent="${opt_args[$k]}"
    fi
  done
  if [[ -z "${selected_torrent}" ]]; then
    _message -r "no torrent was selected on the command line enabling completion of files"
    return
  fi
  local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"})
  local -a parts
  local -a files
  local torrent_name
  for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do
    parts=(${(@s. .)files_info_lines[$f]})
    torrent_name="${parts[7,${#parts[@]}]%/*}"
    if [[ ${parts[3]} != "Normal" ]]; then
      files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"])
    fi
  done
  if [[ -z "${files}" ]]; then
    _message -r "No files are marked with non-high priority in torrent ${torrent_name}"
    return
  fi
  _values -s , -S '-' "files from ${torrent_name}" "${files[@]}"
}
# complete action specified after *--torrent*: `--priority-normal` or `--priority-high`
(( $+functions[_transmission-remote_torrent_priority_not_low] )) ||
_transmission-remote_torrent_priority_not_low(){
  local authentication_args
  for k in '--auth' '--netrc'; do
    authentication_args="${opt_args[${k}]}"
    if ! [[ -z "${authentication_args}" ]]; then
      authentication_args="$k"="${authentication_args}"
      break
    fi
  done
  if [[ -z "${authentication_args}" ]]; then
    for k in '-n' '-N'; do
      authentication_args="${opt_args[${k}]}"
      if ! [[ -z "${authentication_args}" ]]; then
        authentication_args="$k""${authentication_args}"
        break
      fi
    done
  fi
  if [[ -z "${authentication_args}" ]]; then
    for k in '--authenv' '-ne' '--netrc' '-N'; do
      if [[ ${+opt_args[$k]} == "1" ]]; then
        authentication_args="$k"
        break
      fi
    done
  fi
  local selected_torrent
  for k in '-t' '--torrent'; do
    if [[ ! -z ${opt_args[$k]} ]]; then
      selected_torrent="${opt_args[$k]}"
    fi
  done
  if [[ -z "${selected_torrent}" ]]; then
    _message -r "no torrent was selected on the command line enabling completion of files"
    return
  fi
  local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"})
  local -a parts
  local -a files
  local torrent_name
  for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do
    parts=(${(@s. .)files_info_lines[$f]})
    torrent_name="${parts[7,${#parts[@]}]%/*}"
    if [[ ${parts[3]} != "Low" ]]; then
      files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"])
    fi
  done
  if [[ -z "${files}" ]]; then
    _message -r "No files are marked with non-high priority in torrent ${torrent_name}"
    return
  fi
  _values -s , -S '-' "files from ${torrent_name}" "${files[@]}"
}
# complete action specified after *--torrent*: `--tracker-remove`
(( $+functions[_transmission-remote_torrent_tracker_id] )) ||
_transmission-remote_torrent_tracker_id(){
  local authentication_args
  for k in '--auth' '--netrc'; do
    authentication_args="${opt_args[${k}]}"
    if ! [[ -z "${authentication_args}" ]]; then
      authentication_args="$k"="${authentication_args}"
      break
    fi
  done
  if [[ -z "${authentication_args}" ]]; then
    for k in '-n' '-N'; do
      authentication_args="${opt_args[${k}]}"
      if ! [[ -z "${authentication_args}" ]]; then
        authentication_args="$k""${authentication_args}"
        break
      fi
    done
  fi
  if [[ -z "${authentication_args}" ]]; then
    for k in '--authenv' '-ne' '--netrc' '-N'; do
      if [[ ${+opt_args[$k]} == "1" ]]; then
        authentication_args="$k"
        break
      fi
    done
  fi
  local selected_torrent
  for k in '-t' '--torrent'; do
    if [[ ! -z ${opt_args[$k]} ]]; then
      selected_torrent="${opt_args[$k]}"
    fi
  done
  if [[ -z "${selected_torrent}" ]]; then
    _message -r "no torrent was selected on the command line enabling completion of files"
    return
  fi
  local trackers_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent $selected_torrent --info-trackers 2> /dev/null)"})
  local -a parts
  local -a trackers_urls trackers_ids 
  for (( t = 1; t < ${#trackers_info_lines[@]}; ++t )); do
    parts=(${(@s. .)trackers_info_lines[$t]})
    if [[ ( ${parts[1]} == "Tracker" && ${parts[2]} =~ "[0-9]+:" ) ]]; then
      trackers_ids+=("${parts[2]%:}")
      # descriptions passed to _describe need to have their ':' quoted.
      trackers_urls+=("${parts[3]//:/\\:}")
    fi
  done
  if [[ -z "${trackers_ids}" ]]; then
    _message -r "Specified torrent has no trackers"
    return
  fi
  _describe -t trackers-remove "tracker" trackers_urls trackers_ids
}

# The real thing goes here
_arguments \
  "${general_options[@]}" \
  "${global_only_actions[@]}" \
  "${general_actions[@]}" \
  "${torrent_add_options[@]}" \
  "${torrent_action_only_actions[@]}"