| 1 |
#compdef doit |
| 2 |
|
| 3 |
_doit() { |
| 4 |
local -a commands tasks |
| 5 |
# format is 'completion:description' |
| 6 |
commands=( |
| 7 |
'auto: automatically execute tasks when a dependency changes' |
| 8 |
'clean: clean action / remove targets' |
| 9 |
'dumpdb: dump dependency DB' |
| 10 |
'forget: clear successful run status from internal DB' |
| 11 |
'help: show help' |
| 12 |
'ignore: ignore task (skip) on subsequent runs' |
| 13 |
'info: show info about a task' |
| 14 |
'list: list tasks from dodo file' |
| 15 |
'reset-dep: recompute and save the state of file dependencies without executing actions' |
| 16 |
'run: run tasks' |
| 17 |
'strace: use strace to list file_deps and targets' |
| 18 |
'tabcompletion: generate script for tab-completion' |
| 19 |
) |
| 20 |
|
| 21 |
# split output by lines to create an array |
| 22 |
tasks=("${(f)$(doit list --template '{name}: {doc}')}") |
| 23 |
|
| 24 |
# complete command or task name |
| 25 |
if (( CURRENT == 2 )); then |
| 26 |
_arguments -A : '::cmd:(($commands))' '::task:(($tasks))' |
| 27 |
return |
| 28 |
fi |
| 29 |
|
| 30 |
# revome program name from $words and decrement CURRENT |
| 31 |
local curcontext context state state_desc line |
| 32 |
_arguments -C '*:: :->' |
| 33 |
|
| 34 |
# complete sub-command or task options |
| 35 |
local -a _command_args |
| 36 |
case "$words[1]" in |
| 37 |
|
| 38 |
(auto) |
| 39 |
_command_args=( |
| 40 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 41 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 42 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 43 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 44 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 45 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 46 |
'(-v|--verbosity)'{-v,--verbosity}'[0 capture (do not print) stdout/stderr from task. 1 capture stdout only. 2 do not capture anything (print everything immediately). [default: 1\]]' \ |
| 47 |
|
| 48 |
'*::task:(($tasks))' |
| 49 |
'' |
| 50 |
) |
| 51 |
;; |
| 52 |
|
| 53 |
|
| 54 |
(clean) |
| 55 |
_command_args=( |
| 56 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 57 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 58 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 59 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 60 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 61 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 62 |
'(-c|--clean-dep)'{-c,--clean-dep}'[clean task dependencies too]' \ |
| 63 |
'(-a|--clean-all)'{-a,--clean-all}'[clean all task]' \ |
| 64 |
'(-n|--dry-run)'{-n,--dry-run}'[print actions without really executing them]' \ |
| 65 |
'*::task:(($tasks))' |
| 66 |
'' |
| 67 |
) |
| 68 |
;; |
| 69 |
|
| 70 |
|
| 71 |
(dumpdb) |
| 72 |
_command_args=( |
| 73 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 74 |
'' |
| 75 |
) |
| 76 |
;; |
| 77 |
|
| 78 |
|
| 79 |
(forget) |
| 80 |
_command_args=( |
| 81 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 82 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 83 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 84 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 85 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 86 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 87 |
'(-s|--follow-sub)'{-s,--follow-sub}'[forget task dependencies too]' \ |
| 88 |
'*::task:(($tasks))' |
| 89 |
'' |
| 90 |
) |
| 91 |
;; |
| 92 |
|
| 93 |
|
| 94 |
(help) |
| 95 |
_command_args=( |
| 96 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 97 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 98 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 99 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 100 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 101 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 102 |
'*::task:(($tasks))' |
| 103 |
'::cmd:(($commands))' |
| 104 |
'' |
| 105 |
) |
| 106 |
;; |
| 107 |
|
| 108 |
|
| 109 |
(ignore) |
| 110 |
_command_args=( |
| 111 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 112 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 113 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 114 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 115 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 116 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 117 |
'*::task:(($tasks))' |
| 118 |
'' |
| 119 |
) |
| 120 |
;; |
| 121 |
|
| 122 |
|
| 123 |
(info) |
| 124 |
_command_args=( |
| 125 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 126 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 127 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 128 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 129 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 130 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 131 |
'*::task:(($tasks))' |
| 132 |
'' |
| 133 |
) |
| 134 |
;; |
| 135 |
|
| 136 |
|
| 137 |
(list) |
| 138 |
_command_args=( |
| 139 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 140 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 141 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 142 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 143 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 144 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 145 |
'--all[list include all sub-tasks from dodo file]' \ |
| 146 |
'(-q|--quiet)'{-q,--quiet}'[print just task name (less verbose than default)]' \ |
| 147 |
'(-s|--status)'{-s,--status}'[print task status (R)un, (U)p-to-date, (I)gnored]' \ |
| 148 |
'(-p|--private)'{-p,--private}'[print private tasks (start with '_')]' \ |
| 149 |
'--deps[print list of dependencies (file dependencies only)]' \ |
| 150 |
'--template[display entries with template]' \ |
| 151 |
'*::task:(($tasks))' |
| 152 |
'' |
| 153 |
) |
| 154 |
;; |
| 155 |
|
| 156 |
|
| 157 |
(reset-dep) |
| 158 |
_command_args=( |
| 159 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 160 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 161 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 162 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 163 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 164 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 165 |
'*::task:(($tasks))' |
| 166 |
'' |
| 167 |
) |
| 168 |
;; |
| 169 |
|
| 170 |
|
| 171 |
(run) |
| 172 |
_command_args=( |
| 173 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 174 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 175 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 176 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 177 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 178 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 179 |
'(-a|--always-execute)'{-a,--always-execute}'[always execute tasks even if up-to-date [default: %(default)s\]]' \ |
| 180 |
'(-c|--continue)'{-c,--continue}'[continue executing tasks even after a failure [default: %(default)s\]]' \ |
| 181 |
'(-v|--verbosity)'{-v,--verbosity}'[0 capture (do not print) stdout/stderr from task. 1 capture stdout only. 2 do not capture anything (print everything immediately). [default: 1\]]' \ |
| 182 |
'(-r|--reporter)'{-r,--reporter}'[Choose output reporter. [default: %(default)s\]]' \ |
| 183 |
'(-o|--output-file)'{-o,--output-file}'[write output into file [default: stdout\]]' \ |
| 184 |
'(-n|--process)'{-n,--process}'[number of subprocesses [default: %(default)s\]]' \ |
| 185 |
'(-P|--parallel-type)'{-P,--parallel-type}'[Tasks can be executed in parallel in different ways: 'process': uses python multiprocessing module 'thread': uses threads [default: %(default)s\] ]' \ |
| 186 |
'--pdb[get into PDB (python debugger) post-mortem in case of unhandled exception]' \ |
| 187 |
'(-s|--single)'{-s,--single}'[Execute only specified tasks ignoring their task_dep [default: %(default)s\]]' \ |
| 188 |
'*::task:(($tasks))' |
| 189 |
'' |
| 190 |
) |
| 191 |
;; |
| 192 |
|
| 193 |
|
| 194 |
(strace) |
| 195 |
_command_args=( |
| 196 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 197 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 198 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 199 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 200 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 201 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 202 |
'(-a|--all)'{-a,--all}'[display all files (not only from within CWD path)]' \ |
| 203 |
'--keep[save strace command output into strace.txt]' \ |
| 204 |
'*::task:(($tasks))' |
| 205 |
'' |
| 206 |
) |
| 207 |
;; |
| 208 |
|
| 209 |
|
| 210 |
(tabcompletion) |
| 211 |
_command_args=( |
| 212 |
'--db-file[file used to save successful runs [default: %(default)s\]]' \ |
| 213 |
'--backend[Select dependency file backend. [default: %(default)s\]]' \ |
| 214 |
'--check_file_uptodate[Choose how to check if files have been modified. Available options [default: %(default)s\]: 'md5': use the md5sum 'timestamp': use the timestamp ]' \ |
| 215 |
'(-f|--file)'{-f,--file}'[load task from dodo FILE [default: %(default)s\]]' \ |
| 216 |
'(-d|--dir)'{-d,--dir}'[set path to be used as cwd directory (file paths on dodo file are relative to dodo.py location).]' \ |
| 217 |
'(-k|--seek-file)'{-k,--seek-file}'[seek dodo file on parent folders [default: %(default)s\]]' \ |
| 218 |
'(-s|--shell)'{-s,--shell}'[Completion code for SHELL. [default: %(default)s\]]' \ |
| 219 |
'--hardcode-tasks[Hardcode tasks from current task list.]' \ |
| 220 |
'' |
| 221 |
) |
| 222 |
;; |
| 223 |
|
| 224 |
|
| 225 |
# default completes task names |
| 226 |
(*) |
| 227 |
_command_args='*::task:(($tasks))' |
| 228 |
;; |
| 229 |
esac |
| 230 |
|
| 231 |
# -A no options will be completed after the first non-option argument |
| 232 |
_arguments -A : $_command_args |
| 233 |
return 0 |
| 234 |
} |
| 235 |
|
| 236 |
_doit |