... | ... |
@@ -1,37 +1,37 @@ |
1 | 1 |
#compdef task |
2 |
-# |
|
3 | 2 |
# zsh completion for taskwarrior |
4 | 3 |
# |
4 |
+# taskwarrior - a command line task list manager. |
|
5 |
+# |
|
5 | 6 |
# Copyright 2010 - 2011 Johannes Schlatow |
6 | 7 |
# Copyright 2009 P.C. Shyamshankar |
7 |
-# All rights reserved. |
|
8 |
-# |
|
9 |
-# This script is part of the taskwarrior project. |
|
10 | 8 |
# |
11 |
-# This program is free software; you can redistribute it and/or modify it under |
|
12 |
-# the terms of the GNU General Public License as published by the Free Software |
|
13 |
-# Foundation; either version 2 of the License, or (at your option) any later |
|
14 |
-# version. |
|
9 |
+# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
10 |
+# of this software and associated documentation files (the "Software"), to deal |
|
11 |
+# in the Software without restriction, including without limitation the rights |
|
12 |
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
13 |
+# copies of the Software, and to permit persons to whom the Software is |
|
14 |
+# furnished to do so, subject to the following conditions: |
|
15 | 15 |
# |
16 |
-# This program is distributed in the hope that it will be useful, but WITHOUT |
|
17 |
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
18 |
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
19 |
-# details. |
|
16 |
+# The above copyright notice and this permission notice shall be included |
|
17 |
+# in all copies or substantial portions of the Software. |
|
20 | 18 |
# |
21 |
-# You should have received a copy of the GNU General Public License along with |
|
22 |
-# this program; if not, write to the |
|
19 |
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
20 |
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
21 |
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
22 |
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
23 |
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
24 |
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
25 |
+# SOFTWARE. |
|
23 | 26 |
# |
24 |
-# Free Software Foundation, Inc., |
|
25 |
-# 51 Franklin Street, Fifth Floor, |
|
26 |
-# Boston, MA |
|
27 |
-# 02110-1301 |
|
28 |
-# USA |
|
27 |
+# http://www.opensource.org/licenses/mit-license.php |
|
29 | 28 |
# |
30 | 29 |
typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers |
31 | 30 |
_task_projects=($(task _projects)) |
32 | 31 |
_task_tags=($(task _tags)) |
33 | 32 |
_task_ids=($(task _ids)) |
34 | 33 |
_task_config=($(task _config)) |
34 |
+_task_columns=($(task _columns)) |
|
35 | 35 |
_task_modifiers=( |
36 | 36 |
'before' \ |
37 | 37 |
'after' \ |
... | ... |
@@ -46,39 +46,19 @@ _task_modifiers=( |
46 | 46 |
'word' \ |
47 | 47 |
'noword' |
48 | 48 |
) |
49 |
+_task_conjunctions=( |
|
50 |
+ 'and' \ |
|
51 |
+ 'or' \ |
|
52 |
+ 'xor' \ |
|
53 |
+ '\)' |
|
54 |
+ '\(' |
|
55 |
+) |
|
49 | 56 |
_task_cmds=($(task _commands)) |
50 | 57 |
_task_zshcmds=( ${(f)"$(task _zshcommands)"} ) |
51 | 58 |
|
52 |
- |
|
53 |
-_task_idCmds=( |
|
54 |
- 'append' \ |
|
55 |
- 'prepend' \ |
|
56 |
- 'annotate' \ |
|
57 |
- 'denotate' \ |
|
58 |
- 'edit' \ |
|
59 |
- 'duplicate' \ |
|
60 |
- 'info' \ |
|
61 |
- 'start' \ |
|
62 |
- 'stop' \ |
|
63 |
- 'done' |
|
64 |
-) |
|
65 |
- |
|
66 |
-_task_idCmdsDesc=( |
|
67 |
- 'append:Appends more description to an existing task.' \ |
|
68 |
- 'prepend:Prepends more description to an existing task.' \ |
|
69 |
- 'annotate:Adds an annotation to an existing task.' \ |
|
70 |
- 'denotate:Deletes an annotation of an existing task.' \ |
|
71 |
- 'edit:Launches an editor to let you modify a task directly.' \ |
|
72 |
- 'duplicate:Duplicates the specified task, and allows modifications.' \ |
|
73 |
- 'info:Shows all data, metadata for specified task.' \ |
|
74 |
- 'start:Marks specified task as started.' \ |
|
75 |
- 'stop:Removes the start time from a task.' \ |
|
76 |
- 'done:Marks the specified task as completed.' |
|
77 |
-) |
|
78 |
- |
|
79 | 59 |
_task() { |
80 | 60 |
_arguments -s -S \ |
81 |
- "*::task command:_task_commands" |
|
61 |
+ "*::task default:_task_default" |
|
82 | 62 |
return 0 |
83 | 63 |
} |
84 | 64 |
|
... | ... |
@@ -148,6 +128,7 @@ _regex_words values 'task frequencies' \ |
148 | 148 |
'weekly:Every week' \ |
149 | 149 |
'biweekly:Every two weeks' \ |
150 | 150 |
'fortnight:Every two weeks' \ |
151 |
++ 'monthly:Every month' \ |
|
151 | 152 |
'quarterly:Every three months' \ |
152 | 153 |
'semiannual:Every six months' \ |
153 | 154 |
'annual:Every year' \ |
... | ... |
@@ -196,22 +177,13 @@ _regex_arguments _task_attributes "${args[@]}" |
196 | 196 |
|
197 | 197 |
## task commands |
198 | 198 |
|
199 |
-# default completion |
|
200 |
-(( $+functions[_task_default] )) || |
|
201 |
-_task_default() { |
|
199 |
+# filter completion |
|
200 |
+(( $+functions[_task_filter] )) || |
|
201 |
+_task_filter() { |
|
202 | 202 |
_task_attributes "$@" |
203 |
-} |
|
204 | 203 |
|
205 |
-# commands expecting an ID |
|
206 |
-(( $+functions[_task_id] )) || |
|
207 |
-_task_id() { |
|
208 |
- if (( CURRENT < 3 )); then |
|
209 |
- # update IDs |
|
210 |
- _task_zshids=( ${(f)"$(task _zshids)"} ) |
|
211 |
- _describe -t values 'task IDs' _task_zshids |
|
212 |
- else |
|
213 |
- _task_attributes "$@" |
|
214 |
- fi |
|
204 |
+ # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command |
|
205 |
+ _describe -t default 'task conjunctions' _task_conjunctions |
|
215 | 206 |
} |
216 | 207 |
|
217 | 208 |
# merge completion |
... | ... |
@@ -235,46 +207,42 @@ _task_pull() { |
235 | 235 |
_files |
236 | 236 |
} |
237 | 237 |
|
238 |
+# execute completion |
|
239 |
+(( $+functions[_task_execute] )) || |
|
240 |
+_task_execute() { |
|
241 |
+ _files |
|
242 |
+} |
|
238 | 243 |
|
239 |
-# modify (task [0-9]* ...) completion |
|
240 |
-(( $+functions[_task_modify] )) || |
|
241 |
-_task_modify() { |
|
242 |
- _describe -t commands 'task command' _task_idCmdsDesc |
|
243 |
- _task_attributes "$@" |
|
244 |
+# id-only completion |
|
245 |
+(( $+functions[_task_id] )) || |
|
246 |
+_task_id() { |
|
247 |
+ _describe -t values 'task IDs' _task_zshids |
|
244 | 248 |
} |
245 | 249 |
|
246 | 250 |
## first level completion => task sub-command completion |
247 |
-(( $+functions[_task_commands] )) || |
|
248 |
-_task_commands() { |
|
251 |
+(( $+functions[_task_default] )) || |
|
252 |
+_task_default() { |
|
249 | 253 |
local cmd ret=1 |
250 |
- if (( CURRENT == 1 )); then |
|
251 |
- # update IDs |
|
252 |
- _task_zshids=( ${(f)"$(task _zshids)"} ) |
|
253 |
- |
|
254 |
- _describe -t commands 'task command' _task_zshcmds |
|
255 |
- _describe -t values 'task IDs' _task_zshids |
|
256 |
- # TODO match more than one ID |
|
257 |
- elif [[ $words[1] =~ ^[0-9]*$ ]] then |
|
258 |
- _call_function ret _task_modify |
|
259 |
- return ret |
|
260 |
- else |
|
261 |
-# local curcontext="${curcontext}" |
|
262 |
-# cmd="${_task_cmds[(r)$words[1]:*]%%:*}" |
|
263 |
- cmd="${_task_cmds[(r)$words[1]]}" |
|
264 |
- idCmd="${(M)_task_idCmds[@]:#$words[1]}" |
|
265 |
- if (( $#cmd )); then |
|
266 |
-# curcontext="${curcontext%:*:*}:task-${cmd}" |
|
267 | 254 |
|
268 |
- if (( $#idCmd )); then |
|
269 |
- _call_function ret _task_id |
|
270 |
- else |
|
271 |
- _call_function ret _task_${cmd} || |
|
272 |
- _call_function ret _task_default || |
|
273 |
- _message "No command remaining." |
|
274 |
- fi |
|
275 |
- else |
|
276 |
- _message "Unknown subcommand ${cmd}" |
|
277 |
- fi |
|
278 |
- return ret |
|
279 |
- fi |
|
255 |
+ integer i=1 |
|
256 |
+ while (( i < $#words )) |
|
257 |
+ do |
|
258 |
+ cmd="${_task_cmds[(r)$words[$i]]}" |
|
259 |
+ if (( $#cmd )); then |
|
260 |
+ _call_function ret _task_${cmd} || |
|
261 |
+ _call_function ret _task_filter || |
|
262 |
+ _message "No command remaining." |
|
263 |
+ return ret |
|
264 |
+ fi |
|
265 |
+ (( i++ )) |
|
266 |
+ done |
|
267 |
+ |
|
268 |
+ # update IDs |
|
269 |
+ _task_zshids=( ${(f)"$(task _zshids)"} ) |
|
270 |
+ |
|
271 |
+ _describe -t commands 'task command' _task_zshcmds |
|
272 |
+ _describe -t values 'task IDs' _task_zshids |
|
273 |
+ _call_function ret _task_filter |
|
274 |
+ |
|
275 |
+ return ret |
|
280 | 276 |
} |