blob: 0368a2493f54001acb6d265a678472490350b0f7 (
plain)
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
|
#compdef devtodo todo tda tde tdd tdr
## completion for devtodo 0.1.20 <http://swapoff.org/DevTodo>
## Copyright (C) 2008 by Daniel Friesel <derf@derf.homelinux.org>
## License: WTFPL <http://sam.zoy.org/wtfpl>
typeset -a arg_generic arg_add todo_opts \
priorities
typeset -A arg_pair arg_desc
typeset -i i
typeset expl
for ((i=2; i <= $#words; i++)) {
if [[ $words[$i] == '--database' ]] {
todo_opts+=(--database ${~words[$((++i))]})
}
}
priorities=(verylow low medium high veryhigh)
arg_add=(
'-p[priority]:priority:_priority'
'-g[parent item]:parent:_index'
)
arg_generic=(
'--remove[remove items]:index:_index'
'--database[database file]:file:_files'
'--global-database[global database file]:file:_files'
'*--colour[item color]:color:_color'
'--force-colour[force use of colors]'
'--mono[no colors]'
'--help[display help]'
'--version[display version]'
'--title[todo title]:string: '
'--date-format[strftime time formet]:time string: '
'*--format[define format]:format:_format'
'*--use-format[output format]:format:_format'
'--sort[sort database]:expression: '
'--paranoid[paranoid parmissions etc]'
'--database-loaders[loader order]:database loader: '
'--backup[backup database]:count: '
'--timeout[display timeout]:seconds: '
'--purge[purge completed items]:days: '
'*'{'--filter','-f'}'[show items matching filter]:filter:_filter'
# '*::item:_index'
)
arg_pair=(
'verbose' 'v'
'add' 'a'
'graft' 'g'
'link' 'l'
'reparent' 'R'
'priority' 'p'
'edit' 'e'
'done' 'd'
'not-done' 'D'
'global' 'G'
'TODO' 'T'
'all' 'A'
)
arg_desc=(
'verbose' '[be verbose]'
'add' '[add item]:item'
'graft' '[parent item]:parent:_index'
'link' '[link file into database]:database:_files'
'reparent' '[change item parent]:index:_index'
'priority' '[item priority]:priority:_priority'
'edit' '[edit item]:index:_index'
'done' '[mark as done]:index:_index'
'not-done' '[mark as undone]:index:_index -u'
'global' '[use global database]'
'TODO' '[generate TODO file]'
'all' '[show all items]'
)
for arg in ${(k)arg_pair}; {
arg_generic+='(--'$arg')-'${arg_pair[$arg]}${arg_desc[$arg]}
arg_generic+='(-'${arg_pair[$arg]}')--'${arg}${arg_desc[$arg]}
}
function _index () {
typeset i
typeset -a index desc
for i in $*; do
case $i in
-u) todo_opts+=(--filter done)
esac
done
for i in $(todo $todo_opts --format display='%n '); do
index+=${i}:$(todo $todo_opts --format display='%t' $i)
done
_describe -t items index index
}
function _color () {
if compset -P '*='; then
_wanted color expl 'color' \
compadd black red green yellow blue magenta cyan white default
else
_wanted item expl 'item' \
compadd -S '=' $priorities title info
fi
}
function _filter {
typeset prefix
if [[ ${#${words[$CURRENT]}} -gt 0 ]] {
prefix=${${words[$CURRENT]}[1]}
_wanted expression expl 'filter expression' \
compadd -p $prefix -- all children done $priorities
} else {
# XXX the '-' makes problems
_wanted expression expl 'filter expression' \
compadd -S '' -- - + = all children done $priorities
}
}
function _format () {
typeset prefix
if [[ -prefix *= ]] {
_message 'format string'
} else {
_wanted expression expl 'format name' \
compadd -S '=' display generated verbose-display verbose-generated
}
}
function _priority () {
_wanted priority expl 'priority' \
compadd default $priorities
}
case $service in
tda)
_arguments -s $arg_add
;;
tde|tdd)
_arguments -s ':index:_index'
;;
tdr)
zstyle ':completion:*:tdr:*' ignore-line yes
_arguments -s '*:index:_index'
;;
*todo)
_arguments -s $arg_generic
;;
esac
|