task-track 0.6.1

A JJ workspace-based task and TODO management CLI tool
Documentation
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
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
#compdef track

# Dynamic completion helper functions for track CLI
# These functions call 'track _complete' to get dynamic data

_track_tasks() {
    local -a tasks
    local line
    while IFS=: read -r id rest; do
        tasks+=("$id:$rest")
    done < <(track _complete tasks 2>/dev/null)
    _describe 'task' tasks
}

_track_todos() {
    local -a todos
    local line
    while IFS=: read -r id content; do
        todos+=("$id:$content")
    done < <(track _complete todos 2>/dev/null)
    _describe 'todo' todos
}

_track_links() {
    local -a links
    local line
    while IFS=: read -r id title url; do
        links+=("$id:$title")
    done < <(track _complete links 2>/dev/null)
    _describe 'link' links
}

_track_repos() {
    local -a repos
    local line
    while IFS=: read -r id path; do
        repos+=("$id:$path")
    done < <(track _complete repos 2>/dev/null)
    _describe 'repository' repos
}

# Main completion function
autoload -U is-at-least

_track() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_track_commands" \
"*::: :->track" \
&& ret=0
    case $state in
    (track)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:track-command-$line[1]:"
        case $line[1] in
            (new)
_arguments "${_arguments_options[@]}" : \
'-d+[Task description]:DESCRIPTION:_default' \
'--description=[Task description]:DESCRIPTION:_default' \
'-t+[Ticket ID]:TICKET:_default' \
'--ticket=[Ticket ID]:TICKET:_default' \
'--ticket-url=[Ticket URL]:TICKET_URL:_default' \
'--template=[Template task reference]:TEMPLATE:_track_tasks' \
'-h[Print help]' \
'--help[Print help]' \
':name -- Task name:_default' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'-a[Include archived tasks]' \
'--all[Include archived tasks]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(switch)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':task_ref -- Task ID or reference:_track_tasks' \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
'-j[Output in JSON format]' \
'--json[Output in JSON format]' \
'-a[Show all scraps]' \
'--all[Show all scraps]' \
'-h[Print help]' \
'--help[Print help]' \
'::id -- Task ID or reference:_track_tasks' \
&& ret=0
;;
(desc)
_arguments "${_arguments_options[@]}" : \
'-t+[Target task ID]:TASK:_default' \
'--task=[Target task ID]:TASK:_default' \
'-h[Print help]' \
'--help[Print help]' \
'::description:_default' \
&& ret=0
;;
(ticket)
_arguments "${_arguments_options[@]}" : \
'--task=[Target task ID]:TASK:_default' \
'-h[Print help]' \
'--help[Print help]' \
':ticket_id:_default' \
':url:_default' \
&& ret=0
;;
(archive)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'::task_ref:_track_tasks' \
&& ret=0
;;
(todo)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_track__todo_commands" \
"*::: :->todo" \
&& ret=0

case $state in
    (todo)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:track-todo-command-$line[1]:"
        case $line[1] in
            (add)
_arguments "${_arguments_options[@]}" : \
'-w[Create worktrees for this TODO]' \
'--worktree[Create worktrees for this TODO]' \
'-h[Print help]' \
'--help[Print help]' \
':text -- TODO content:_default' \
&& ret=0
;;
            (list)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
            (update)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':id -- TODO ID:_track_todos' \
':status -- New status:(pending done cancelled)' \
&& ret=0
;;
            (done)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':id -- TODO ID:_track_todos' \
&& ret=0
;;
            (delete)
_arguments "${_arguments_options[@]}" : \
'-f[Skip confirmation]' \
'--force[Skip confirmation]' \
'-h[Print help]' \
'--help[Print help]' \
':id -- TODO ID:_track_todos' \
&& ret=0
;;
            (next)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':id -- TODO ID:_track_todos' \
&& ret=0
;;
        esac
    ;;
esac
;;
(link)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_track__link_commands" \
"*::: :->link" \
&& ret=0

case $state in
    (link)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:track-link-command-$line[1]:"
        case $line[1] in
            (add)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':url:_default' \
'::title:_default' \
&& ret=0
;;
            (list)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
            (delete)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':index -- Link index:_track_links' \
&& ret=0
;;
        esac
    ;;
esac
;;
(scrap)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_track__scrap_commands" \
"*::: :->scrap" \
&& ret=0

case $state in
    (scrap)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:track-scrap-command-$line[1]:"
        case $line[1] in
            (add)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':content:_default' \
&& ret=0
;;
            (list)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
        esac
    ;;
esac
;;
(sync)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(repo)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_track__repo_commands" \
"*::: :->repo" \
&& ret=0

case $state in
    (repo)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:track-repo-command-$line[1]:"
        case $line[1] in
            (add)
_arguments "${_arguments_options[@]}" : \
'-b+[Base branch]:BASE:_default' \
'--base=[Base branch]:BASE:_default' \
'-h[Print help]' \
'--help[Print help]' \
'::path:_files -/' \
&& ret=0
;;
            (list)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
            (remove)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':id -- Repository ID:_track_repos' \
&& ret=0
;;
        esac
    ;;
esac
;;
(alias)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_track__alias_commands" \
"*::: :->alias" \
&& ret=0

case $state in
    (alias)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:track-alias-command-$line[1]:"
        case $line[1] in
            (set)
_arguments "${_arguments_options[@]}" : \
'-t+[Target task ID]:TASK:_default' \
'--task=[Target task ID]:TASK:_default' \
'-f[Force overwrite]' \
'--force[Force overwrite]' \
'-h[Print help]' \
'--help[Print help]' \
':alias:_default' \
&& ret=0
;;
            (remove)
_arguments "${_arguments_options[@]}" : \
'-t+[Target task ID]:TASK:_default' \
'--task=[Target task ID]:TASK:_default' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
        esac
    ;;
esac
;;
(llm-help)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(completion)
_arguments "${_arguments_options[@]}" : \
'-d[Generate dynamic completion]' \
'--dynamic[Generate dynamic completion]' \
'-h[Print help]' \
'--help[Print help]' \
':shell:(bash zsh fish powershell)' \
&& ret=0
;;
(config)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_track__config_commands" \
"*::: :->config" \
&& ret=0

case $state in
    (config)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:track-config-command-$line[1]:"
        case $line[1] in
            (set-calendar)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':calendar_id:_default' \
&& ret=0
;;
            (show)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
        esac
    ;;
esac
;;
(webui)
_arguments "${_arguments_options[@]}" : \
'-p+[Port]:PORT:_default' \
'--port=[Port]:PORT:_default' \
'-o[Open browser]' \
'--open[Open browser]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_track__help_commands" \
"*::: :->help" \
&& ret=0

case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:track-help-command-$line[1]:"
        case $line[1] in
            (new|list|switch|status|desc|ticket|archive|todo|link|scrap|sync|repo|alias|llm-help|completion|config|webui|help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_track_commands] )) ||
_track_commands() {
    local commands; commands=(
'new:Create a new task and switch to it' \
'list:List tasks' \
'switch:Switch to a different task' \
'status:Show detailed information about the current task' \
'desc:View or set task description' \
'ticket:Link a ticket to a task' \
'archive:Archive a task' \
'todo:TODO management' \
'link:Link management' \
'scrap:Scrap (work notes) management' \
'sync:Sync repositories and setup task branches' \
'repo:Repository management' \
'alias:Task alias management' \
'llm-help:Show help optimized for LLM agents' \
'completion:Generate shell completion script' \
'config:Configuration management' \
'webui:Start web-based user interface' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'track commands' commands "$@"
}

(( $+functions[_track__todo_commands] )) ||
_track__todo_commands() {
    local commands; commands=(
'add:Add a new TODO' \
'list:List TODOs' \
'update:Update TODO status' \
'done:Complete a TODO' \
'delete:Delete a TODO' \
'next:Move a TODO to the front' \
    )
    _describe -t commands 'track todo commands' commands "$@"
}

(( $+functions[_track__link_commands] )) ||
_track__link_commands() {
    local commands; commands=(
'add:Add a new link' \
'list:List links' \
'delete:Delete a link' \
    )
    _describe -t commands 'track link commands' commands "$@"
}

(( $+functions[_track__scrap_commands] )) ||
_track__scrap_commands() {
    local commands; commands=(
'add:Add a new scrap' \
'list:List scraps' \
    )
    _describe -t commands 'track scrap commands' commands "$@"
}

(( $+functions[_track__repo_commands] )) ||
_track__repo_commands() {
    local commands; commands=(
'add:Add a repository' \
'list:List repositories' \
'remove:Remove a repository' \
    )
    _describe -t commands 'track repo commands' commands "$@"
}

(( $+functions[_track__alias_commands] )) ||
_track__alias_commands() {
    local commands; commands=(
'set:Set an alias for the current task' \
'remove:Remove the alias from the current task' \
    )
    _describe -t commands 'track alias commands' commands "$@"
}

(( $+functions[_track__config_commands] )) ||
_track__config_commands() {
    local commands; commands=(
'set-calendar:Set Google Calendar ID' \
'show:Show current configuration' \
    )
    _describe -t commands 'track config commands' commands "$@"
}

(( $+functions[_track__help_commands] )) ||
_track__help_commands() {
    local commands; commands=(
'new:Create a new task and switch to it' \
'list:List tasks' \
'switch:Switch to a different task' \
'status:Show detailed information' \
'desc:View or set task description' \
'ticket:Link a ticket to a task' \
'archive:Archive a task' \
'todo:TODO management' \
'link:Link management' \
'scrap:Scrap management' \
'sync:Sync repositories' \
'repo:Repository management' \
'alias:Task alias management' \
'llm-help:Show LLM help' \
'completion:Generate completion script' \
'config:Configuration management' \
'webui:Start web UI' \
'help:Print help' \
    )
    _describe -t commands 'help commands' commands "$@"
}

_track "$@"