Blame view

plugins/django/django.plugin.zsh 13.5 KB
093a6c34b   mj   Squashed 'repos/r...
1
2
3
4
  #compdef manage.py
  
  typeset -ga nul_args
  nul_args=(
9f5c61b70   mj   Squashed 'repos/r...
5
    '--verbosity=-[verbosity level; 0=minimal output, 1=normal output, 2=all output.]:Verbosity:((0\:minimal 1\:normal 2\:all))'
093a6c34b   mj   Squashed 'repos/r...
6
    '--settings=-[the Python path to a settings module.]:file:_files'
9f5c61b70   mj   Squashed 'repos/r...
7
    '--pythonpath=-[a directory to add to the Python path.]:directory:_directories'
093a6c34b   mj   Squashed 'repos/r...
8
    '--traceback[print traceback on exception.]'
9f5c61b70   mj   Squashed 'repos/r...
9
    "--no-color[Don't colorize the command output.]"
093a6c34b   mj   Squashed 'repos/r...
10
11
12
    "--version[show program's version number and exit.]"
    {-h,--help}'[show this help message and exit.]'
  )
9f5c61b70   mj   Squashed 'repos/r...
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
  typeset -ga start_args
  start_args=(
    '--template=-[The path or URL to load the template from.]:directory:_directories'
    '--extension=-[The file extension(s) to render (default: "py").]'
    '--name=-[The file name(s) to render.]:file:_files'
  )
  
  typeset -ga db_args
  db_args=(
    '--database=-[Nominates a database. Defaults to the "default" database.]'
  )
  
  typeset -ga noinput_args
  noinput_args=(
    '--noinput[tells Django to NOT prompt the user for input of any kind.]'
  )
  
  typeset -ga no_init_data_args
  no_init_data_args=(
    '--no-initial-data[Tells Django not to load any initial data after database synchronization.]'
  )
  
  typeset -ga tag_args
  tag_args=(
    '--tag=-[Run only checks labeled with given tag.]'
    '--list-tags[List available tags.]'
  )
  
  _managepy-check(){
093a6c34b   mj   Squashed 'repos/r...
42
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
43
44
45
46
47
48
49
50
      $tag_args \
      $nul_args && ret=0
  }
  
  _managepy-changepassword(){
    _arguments -s : \
      $db_args \
      $nul_args && ret=0
093a6c34b   mj   Squashed 'repos/r...
51
52
53
54
  }
  
  _managepy-createcachetable(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
55
56
57
58
59
60
61
62
63
64
      $db_args \
      $nul_args && ret=0
  }
  
  _managepy-createsuperuser(){
    _arguments -s : \
      '--username=-[Specifies the login for the superuser.]' \
      '--email=-[Specifies the email for the superuser.]' \
      $noinput_args \
      $db_args \
093a6c34b   mj   Squashed 'repos/r...
65
66
67
68
69
      $nul_args && ret=0
  }
  
  _managepy-collectstatic(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
70
71
72
73
74
75
76
77
      '--link[Create a symbolic link to each file instead of copying.]' \
      '--no-post-process[Do NOT post process collected files.]' \
      '--ignore=-[Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.]' \
      '--dry-run[Do everything except modify the filesystem.]' \
      '--clear[Clear the existing files using the storage before trying to copy or link the original file.]' \
      '--link[Create a symbolic link to each file instead of copying.]' \
      '--no-default-ignore[Do not ignore the common private glob-style patterns "CVS", ".*" and "*~".]' \
      $noinput_args \
093a6c34b   mj   Squashed 'repos/r...
78
79
80
81
82
      $nul_args && ret=0
  }
  
  _managepy-dbshell(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
83
      $db_args \
093a6c34b   mj   Squashed 'repos/r...
84
85
86
87
88
      $nul_args && ret=0
  }
  
  _managepy-diffsettings(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
89
      "--all[Display all settings, regardless of their value.]"
093a6c34b   mj   Squashed 'repos/r...
90
91
92
93
94
      $nul_args && ret=0
  }
  
  _managepy-dumpdata(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
95
96
97
98
99
100
101
102
      '--format=-[Specifies the output serialization format for fixtures.]:format:(json yaml xml)' \
      '--indent=-[Specifies the indent level to use when pretty-printing output.]' \
      '--exclude=-[An app_label or app_label.ModelName to exclude (use multiple --exclude to exclude multiple apps/models).]' \
      '--natural-foreign[Use natural foreign keys if they are available.]' \
      '--natural-primary[Use natural primary keys if they are available.]' \
      "--all[Use Django's base manager to dump all models stored in the database.]" \
      '--pks=-[Only dump objects with given primary keys.]' \
      $db_args \
093a6c34b   mj   Squashed 'repos/r...
103
104
105
106
107
108
      $nul_args \
      '*::appname:_applist' && ret=0
  }
  
  _managepy-flush(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
109
110
111
      $no_init_data_args \
      $db_args \
      $noinput_args \
093a6c34b   mj   Squashed 'repos/r...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
      $nul_args && ret=0
  }
  
  _managepy-help(){
    _arguments -s : \
      '*:command:_managepy_cmds' \
      $nul_args && ret=0
  }
  
  _managepy_cmds(){
      local line
      local -a cmd
      _call_program help-command ./manage.py help \
        |& sed -n '/^ /s/[(), ]/ /gp' \
        | while read -A line; do cmd=($line $cmd) done
      _describe -t managepy-command 'manage.py command' cmd
  }
  
  _managepy-inspectdb(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
132
      $db_args \
093a6c34b   mj   Squashed 'repos/r...
133
134
135
136
137
      $nul_args && ret=0
  }
  
  _managepy-loaddata(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
138
139
      '--ignorenonexistent[Ignores entries in the serialized data for fields that do not currently exist on the model.]' \
      '--app=-[Only look for fixtures in the specified app.]:appname:_applist' \
093a6c34b   mj   Squashed 'repos/r...
140
      '*::file:_files' \
9f5c61b70   mj   Squashed 'repos/r...
141
      $db_args \
093a6c34b   mj   Squashed 'repos/r...
142
143
      $nul_args && ret=0
  }
9f5c61b70   mj   Squashed 'repos/r...
144
  _managepy-makemessages(){
093a6c34b   mj   Squashed 'repos/r...
145
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
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
      '--locale=-[Creates or updates the message files for the given locale(s) (e.g. pt_BR).]' \
      '--domain=-[The domain of the message files (default: "django").]' \
      '--all[Updates the message files for all existing locales.]' \
      '--extension=-[The file extension(s) to examine (default: "html,txt", or "js" if the domain is "djangojs").]' \
      '--symlinks[Follows symlinks to directories when examining source code and templates for translation strings.]' \
      '--ignore=-[Ignore files or directories matching this glob-style pattern.]' \
      "--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \
      "--no-wrap[Don't break long message lines into several lines.]" \
      "--no-location[Don't write '#: filename:line' lines.]" \
      '--no-obsolete[emove obsolete message strings.]' \
      '--keep-pot[Keep .pot file after making messages.]' \
      $nul_args && ret=0
  }
  _managepy-makemigrations(){
    _arguments -s : \
      '--dry-run[Just show what migrations would be made]' \
      '--merge[Enable fixing of migration conflicts.]' \
      '--empty[Create an empty migration.]' \
      $noinput_args \
      $nul_args && ret=0
  }
  _managepy-migrate(){
    _arguments -s : \
      '--fake[Mark migrations as run without actually running them]' \
      '--list[Show a list of all known migrations and which are applied]' \
      $no_init_data_args \
      $noinput_args \
      $db_args \
093a6c34b   mj   Squashed 'repos/r...
174
175
176
177
178
      $nul_args && ret=0
  }
  
  _managepy-runfcgi(){
    local state
9f5c61b70   mj   Squashed 'repos/r...
179

093a6c34b   mj   Squashed 'repos/r...
180
181
182
183
184
    local fcgi_opts
    fcgi_opts=(
      'protocol[fcgi, scgi, ajp, ... (default fcgi)]:protocol:(fcgi scgi ajp)'
      'host[hostname to listen on..]:'
      'port[port to listen on.]:'
9f5c61b70   mj   Squashed 'repos/r...
185
      'socket[UNIX socket to listen on.]:file:_files'
093a6c34b   mj   Squashed 'repos/r...
186
187
188
189
190
191
192
193
194
195
196
      'method[prefork or threaded (default prefork)]:method:(prefork threaded)'
      'maxrequests[number of requests a child handles before it is killed and a new child is forked (0 = no limit).]:'
      'maxspare[max number of spare processes / threads.]:'
      'minspare[min number of spare processes / threads.]:'
      'maxchildren[hard limit number of processes / threads.]:'
      'daemonize[whether to detach from terminal.]:boolean:(False True)'
      'pidfile[write the spawned process-id to this file.]:file:_files'
      'workdir[change to this directory when daemonizing.]:directory:_files'
      'outlog[write stdout to this file.]:file:_files'
      'errlog[write stderr to this file.]:file:_files'
    )
9f5c61b70   mj   Squashed 'repos/r...
197

093a6c34b   mj   Squashed 'repos/r...
198
199
200
201
202
203
204
    _arguments -s : \
      $nul_args \
      '*: :_values "FCGI Setting" $fcgi_opts' && ret=0
  }
  
  _managepy-runserver(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
205
206
207
208
209
      '--ipv6[Tells Django to use an IPv6 address.]' \
      '--nothreading[Tells Django to NOT use threading.]' \
      '--noreload[Tells Django to NOT use the auto-reloader.]' \
      '--nostatic[Tells Django to NOT automatically serve static files at STATIC_URL.]' \
      '--insecure[Allows serving static files even if DEBUG is False.]' \
093a6c34b   mj   Squashed 'repos/r...
210
211
212
213
214
      $nul_args && ret=0
  }
  
  _managepy-shell(){
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
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
      '--plain[Tells Django to use plain Python, not IPython.]' \
      '--no-startup[When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.]' \
      '--interface=-[Specify an interactive interpreter interface.]:INTERFACE:((ipython bpython))' \
      $nul_args && ret=0
  }
  
  _managepy-sql(){
    _arguments -s : \
      $db_args \
      $nul_args && ret=0
  }
  
  _managepy-sqlall(){
    _arguments -s : \
      $db_args \
      $nul_args && ret=0
  }
  
  _managepy-sqlclear(){
    _arguments -s : \
      $db_args \
      $nul_args && ret=0
  }
  
  _managepy-sqlcustom(){
    _arguments -s : \
      $db_args \
      $nul_args && ret=0
  }
  
  _managepy-dropindexes(){
    _arguments -s : \
      $db_args \
093a6c34b   mj   Squashed 'repos/r...
248
249
      $nul_args && ret=0
  }
9f5c61b70   mj   Squashed 'repos/r...
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
  _managepy-sqlflush(){
    _arguments -s : \
      $db_args \
      $nul_args && ret=0
  }
  
  _managepy-sqlindexes(){
    _arguments -s : \
      $db_args \
      $nul_args && ret=0
  }
  
  _managepy-sqlinitialdata(){
    _arguments -s : \
      $nul_args && ret=0
  }
  
  _managepy-sqlsequencereset(){
    _arguments -s : \
      $db_args \
      $nul_args && ret=0
  }
  
  _managepy-squashmigrations(){
    _arguments -s : \
      '--no-optimize[Do not try to optimize the squashed operations.]' \
      $noinput_args \
      $nul_args && ret=0
  }
  
  _managepy-startapp(){
    _arguments -s : \
      $start_args \
      $nul_args && ret=0
  }
  _managepy-startproject(){
    _arguments -s : \
      $start_args \
      $nul_args && ret=0
  }
093a6c34b   mj   Squashed 'repos/r...
290
291
292
  
  _managepy-syncdb() {
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
293
294
295
      $noinput_args \
      $no_init_data_args \
      $db_args \
093a6c34b   mj   Squashed 'repos/r...
296
297
298
299
300
      $nul_args && ret=0
  }
  
  _managepy-test() {
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
301
302
303
304
305
306
      '--failfast[Tells Django to stop running the test suite after first failed test.]' \
      '--testrunner=-[Tells Django to use specified test runner class instead of the one specified by the TEST_RUNNER setting.]' \
      '--liveserver=-[Overrides the default address where the live server (used with LiveServerTestCase) is expected to run from. The default value is localhost:8081.]' \
      '--top-level-directory=-[Top level of project for unittest discovery.]' \
      '--pattern=-[The test matching pattern. Defaults to test*.py.]:' \
      $noinput_args \
093a6c34b   mj   Squashed 'repos/r...
307
308
309
310
311
312
      '*::appname:_applist' \
      $nul_args && ret=0
  }
  
  _managepy-testserver() {
    _arguments -s : \
093a6c34b   mj   Squashed 'repos/r...
313
      '--addrport=-[port number or ipaddr:port to run the server on.]' \
9f5c61b70   mj   Squashed 'repos/r...
314
315
      '--ipv6[Tells Django to use an IPv6 address.]' \
      $noinput_args \
093a6c34b   mj   Squashed 'repos/r...
316
317
318
319
320
321
      '*::fixture:_files' \
      $nul_args && ret=0
  }
  
  _managepy-validate() {
    _arguments -s : \
9f5c61b70   mj   Squashed 'repos/r...
322
      $tag_args \
093a6c34b   mj   Squashed 'repos/r...
323
324
325
326
327
      $nul_args && ret=0
  }
  
  _managepy-commands() {
    local -a commands
9f5c61b70   mj   Squashed 'repos/r...
328

093a6c34b   mj   Squashed 'repos/r...
329
    commands=(
9f5c61b70   mj   Squashed 'repos/r...
330
331
332
333
334
      "changepassword:Change a user's password for django.contrib.auth."
      'check:Checks the entire Django project for potential problems.'
      'compilemessages:Compiles .po files to .mo files for use with builtin gettext support.'
      'createcachetable:Creates the table needed to use the SQL cache backend.'
      'createsuperuser:Used to create a superuser.'
093a6c34b   mj   Squashed 'repos/r...
335
      'collectstatic:Collect static files in a single location.'
9f5c61b70   mj   Squashed 'repos/r...
336
337
      'dbshell:Runs the command-line client for the current DATABASE_ENGINE.'
      "diffsettings:Displays differences between the current settings.py and Django's default settings."
093a6c34b   mj   Squashed 'repos/r...
338
339
340
341
342
      'dumpdata:Output the contents of the database as a fixture of the given format.'
      'flush:Executes ``sqlflush`` on the current database.'
      'help:manage.py help.'
      'inspectdb:Introspects the database tables in the given database and outputs a Django model module.'
      'loaddata:Installs the named fixture(s) in the database.'
9f5c61b70   mj   Squashed 'repos/r...
343
344
345
      'makemessages:Runs over the entire source tree of the current directory and pulls out all strings marked for translation.'
      'makemigrations:Creates new migration(s) for apps.'
      'migrate:Updates database schema. Manages both apps with migrations and those without.'
093a6c34b   mj   Squashed 'repos/r...
346
347
348
349
350
351
352
      'runfcgi:Run this project as a fastcgi (or some other protocol supported by flup) application,'
      'runserver:Starts a lightweight Web server for development.'
      'shell:Runs a Python interactive interpreter.'
      'sql:Prints the CREATE TABLE SQL statements for the given app name(s).'
      'sqlall:Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).'
      'sqlclear:Prints the DROP TABLE SQL statements for the given app name(s).'
      'sqlcustom:Prints the custom table modifying SQL statements for the given app name(s).'
9f5c61b70   mj   Squashed 'repos/r...
353
      'sqldropindexes:Prints the DROP INDEX SQL statements for the given model module name(s).'
093a6c34b   mj   Squashed 'repos/r...
354
355
356
      'sqlflush:Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed.'
      'sqlindexes:Prints the CREATE INDEX SQL statements for the given model module name(s).'
      "sqlinitialdata:RENAMED: see 'sqlcustom'"
093a6c34b   mj   Squashed 'repos/r...
357
      'sqlsequencereset:Prints the SQL statements for resetting sequences for the given app name(s).'
9f5c61b70   mj   Squashed 'repos/r...
358
      'squashmigrations:Squashes an existing set of migrations (from first until specified) into a single new one.'
093a6c34b   mj   Squashed 'repos/r...
359
360
361
362
363
364
365
      "startapp:Creates a Django app directory structure for the given app name in this project's directory."
      "startproject:Creates a Django project directory structure for the given project name in this current directory."
      "syncdb:Create the database tables for all apps in INSTALLED_APPS whose tables haven't already been created."
      'test:Runs the test suite for the specified applications, or the entire site if no apps are specified.'
      'testserver:Runs a development server with data from the given fixture(s).'
      'validate:Validates all installed models.'
    )
9f5c61b70   mj   Squashed 'repos/r...
366

093a6c34b   mj   Squashed 'repos/r...
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
    _describe -t commands 'manage.py command' commands && ret=0
  }
  
  _applist() {
    local line
    local -a apps
    _call_program help-command "python -c \"import os.path as op, re, django.conf, sys;\\
                                            bn=op.basename(op.abspath(op.curdir));[sys\\
                                            .stdout.write(str(re.sub(r'^%s\.(.*?)$' %
                                            bn, r'\1', i)) + '
  ') for i in django.conf.settings.\\
                                            INSTALLED_APPS if re.match(r'^%s' % bn, i)]\"" \
                               | while read -A line; do apps=($line $apps) done
    _values 'Application' $apps && ret=0
  }
  
  _managepy() {
    local curcontext=$curcontext ret=1
9f5c61b70   mj   Squashed 'repos/r...
385

093a6c34b   mj   Squashed 'repos/r...
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
    if ((CURRENT == 2)); then
      _managepy-commands
    else
      shift words
      (( CURRENT -- ))
      curcontext="${curcontext%:*:*}:managepy-$words[1]:"
      _call_function ret _managepy-$words[1]
    fi
  }
  
  compdef _managepy manage.py
  compdef _managepy django
  compdef _managepy django-admin
  compdef _managepy django-admin.py
  compdef _managepy django-manage