forked from zsh-users/zsh-completions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_symfony
451 lines (370 loc) · 12.1 KB
/
_symfony
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
#compdef symfony
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Symfony (http://www.symfony-project.org).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * aki77 (https://github.com/aki77)
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
_symfony () {
local curcontext="$curcontext" state line expl ret=1 cache_version
cache_version=$(_get_sf_cache_var version)
(( ${(P)+cache_version} == 0 )) && {
eval $cache_version=${${${(z)$($service -V)}[3]}%.*}
}
if [ ${(P)cache_version} = "1.0" ] ; then
_symfony10
return
fi
_arguments -C \
'(-T --tasks)'{-T,--tasks}'[list of the symfony tasks]' \
'(-V --version)'{-V,--version}'[version]' \
'1: :->tasks' \
'*:: :->args' && ret=0
case $state in
tasks)
_sf_tasks
;;
args)
local task args
task=$words[1]
args=(
${${${${${(M)${${${(z)${${"$($service help $task)"#*Usage:}#[[:cntrl:]]}%%[[:cntrl:]]*}//\[/}//\]/}:#--*}%%\"*}/=/"=-"}/(#b)--(app|application)=-/--$match[1]=-:application:_sf_apps}//(#b)--(env|environment)=-/--$match[1]=-:environment:_sf_environments}
)
case $task in
help)
args+=(
':task:_sf_tasks'
)
;;
app:routes)
args+=(
':application:_sf_apps'
':"route name":'
)
;;
configure:author)
_message 'project author'
;;
configure:database)
_message 'database dsn'
;;
generate:app)
_message 'new application name'
;;
generate:module)
args+=(
':application:_sf_apps'
':"new module name":'
)
;;
generate:project)
_message 'new project name'
;;
generate:task)
_message 'new task name'
;;
i18n:extract)
args+=(
':application:_sf_apps'
':"target culture":'
)
;;
i18n:find)
args+=(
':application:_sf_apps'
)
;;
log:rotate)
args+=(
':application:_sf_apps'
':environment:_sf_environments'
)
;;
plugin:add-channel)
_message 'channel name'
;;
plugin:install)
_message 'plugin name'
;;
plugin:publish-assets)
args+=(
':plugin:_sf_plugins'
)
;;
plugin:uninstall)
_message 'plugin name'
;;
plugin:upgrade)
_message 'plugin name'
;;
project:deploy)
_message 'server name'
;;
project:disable|project:enable)
args+=(
':environment:_sf_environments'
'*:application:_sf_apps'
)
;;
project:optimize)
args+=(
':application:_sf_apps'
':environment:_sf_environments'
)
;;
propel:data-dump|doctrine:data-dump)
_message 'target filename'
;;
propel:data-load|doctrine:data-load)
args+=(
'*:file:_files'
)
;;
propel:generate-admin)
args+=(
':application:_sf_apps'
':model:_sf_models'
)
;;
propel:generate-module|propel:init-admin)
args+=(
':application:_sf_apps'
':module:_sf_modules_candidate'
':model:_sf_models'
)
;;
propel:generate-module-for-route|doctrine:generate-module-for-route)
args+=(
':application:_sf_apps'
':"route name":'
)
;;
doctrine:create-model-tables|doctrine:delete-model-files)
args+=(
'*:model:_sf_doctrine_models'
)
;;
doctrine:generate-admin)
args+=(
':application:_sf_apps'
'*:model:_sf_doctrine_models'
)
;;
doctrine:generate-module)
args+=(
':application:_sf_apps'
':module:_sf_doctrine_modules_candidate'
':model:_sf_doctrine_models'
)
;;
test:coverage)
args+=(
'*:file:_files'
)
;;
test:functional)
args+=(
':application:_sf_apps'
'*:test:_sf_functionaltests'
)
;;
test:unit)
args+=(
'*:test:_sf_unittests'
)
;;
esac
_arguments "$args[@]" && ret=0
return
;;
esac
return ret
}
_symfony10 () {
local curcontext="$curcontext" state line expl ret=1
_arguments -C \
'(-T --tasks)'{-T,--tasks}'[list of the symfony tasks]' \
'(-V --version)'{-V,--version}'[version]' \
'1: :->tasks' \
'*:: :->args' && ret=0
case $state in
tasks)
_sf10_tasks
;;
args)
local task args
task=$words[1]
args=()
case $task in
init-project)
_message 'new project name'
;;
init-app)
_message 'application name'
;;
init-module)
args+=(
':application:_sf_apps'
)
;;
init-batch)
args+=(
':skeleton name:compadd default rotate'
':"script name":'
':application:_sf_apps'
)
;;
init-controller)
args+=(
':application:_sf_apps'
':environment:_sf_environments'
':"script name":'
':"debug?":compadd true false'
)
;;
log-rotate)
args+=(
':application:_sf_apps'
':environment:_sf_environments'
)
;;
propel-load-data|propel-build-all-load)
args+=(
':application:_sf_apps'
':environment:_sf_environments'
':fixtures:_sf_fixtures'
)
;;
clear-cache|cc)
args+=(
':application:_sf_apps'
':what:compadd template config'
)
;;
sync)
args+=(
':environment:_sf_environments'
':"real run?":compadd go'
)
;;
propel-init-crud|propel*-init-admin|propel-generate-crud)
args+=(
':application:_sf_apps'
':module:_sf_modules_candidate'
':model:_sf_models'
)
;;
doctrine-init-admin|doctrine-generate-crud)
args+=(
':application:_sf_apps'
':module:_sf_doctrine_modules_candidate'
':model:_sf_doctrine_models'
)
;;
test-unit)
args+=(
':test:_sf_unittests'
)
;;
test-functional)
args+=(
':application:_sf_apps'
':test:_sf_functionaltests'
)
;;
esac
_arguments "$args[@]" && ret=0
return
;;
esac
return ret
}
_sf_tasks () {
local tmp ns line cache_task
cache_task=$(_get_sf_cache_var task)
(( ${(P)+cache_task} == 0 )) && {
tmp=(
${${${(f)${"$($service -T)"##*Available tasks:}}##[[:blank:]][[:blank:]]}%%[[:blank:]]*}
)
eval "$cache_task=()"
ns=''
for line in $tmp; do
if [ $line[1] = ":" ] ; then
eval "$cache_task+=( ${ns}${line#:} )"
else
ns="${line}:"
fi
done
}
_wanted symfony-task expl 'Symfony task' compadd -a $cache_task
}
_sf10_tasks () {
local sf_tasks
sf_tasks=(
${${${(f)${"$($service -T)"#available pake tasks:}%%task aliases:*}#[[:blank:]][[:blank:]]}/[[:blank:]]*>[[:blank:]]/:}
)
_describe -t symfony-tasks 'Symfony task' sf_tasks
}
_sf_apps () {
_wanted application expl 'application' compadd \
${$(echo apps/*):t}
}
_sf_environments () {
local app
app=$([ -f apps/"$words[2]"/config/settings.yml ] && echo $words[2] || echo frontend)
if [ -r apps/$app/config/settings.yml ] ; then
_wanted environment expl 'environment' compadd \
${${${(M)${(@f)"$(<apps/$app/config/settings.yml)"}:#[[:alpha:]]*}%%:*}:#all}
fi
}
_sf_plugins () {
_wanted application expl 'plugin' compadd \
${$(echo plugins/*):t}
}
_sf_models () {
_wanted application expl 'model' compadd \
$(_get_sfmodels)
}
_sf_doctrine_models () {
_wanted model expl 'model' compadd \
$(_get_sf_doctrine_models)
}
_sf_modules_candidate () {
_wanted module expl 'module' compadd \
${$(_get_sfmodels):l}
}
_sf_doctrine_modules_candidate () {
_wanted module expl 'module' compadd \
${$(_get_sf_doctrine_models):l}
}
_sf_unittests () {
_wanted test expl 'test' compadd \
${${${$(echo test/unit/**/*Test.php):r}#test/unit/}%Test}
}
_sf_functionaltests () {
_wanted test expl 'test' compadd \
${${$(echo test/functional/$words[2]/*ActionsTest.php):t:r}%Test}
}
_sf_fixtures () {
_files -W $(pwd)/data
}
_get_sfmodels () {
echo ${${$(echo lib/model/*Peer.php):t:r}%Peer}
}
_get_sf_doctrine_models () {
echo ${${$(echo lib/model/doctrine/*Table.class.php):t:r:r}%Table}
}
_get_sf_cache_var () {
echo ${$(echo "_sf_cache_${(j:_:)@}$(pwd)")//[^[:alnum:]]/_}
}
_symfony "$@"