Browse code

zsh: update zsh completion for docker command

zsh completion is updated with the content of
felixr/docker-zsh-completion.

The major change since the last merge is the addition of
exec/create (but they were already present in the docker repository) as
well as pause/unpause/logout/events and the use of short/long options
when they are available. Some missing options were also added.

12f00abd7178 Add completion for `exec'
4e2faa075f9a Merge `run' and `create' commands.
34134de077de Add missing long/short options for most commands.
d09f62339ab5 Add completion for `pause' and `unpause'
e4754c3b3b9d Add completion for `logout'
e0935eb3d5d2 Add completion for `events'
dae353cb9afb Add completion for `create`

Docker-DCO-1.1-Signed-off-by: Vincent Bernat <vincent@bernat.im> (github: vincentbernat)

Vincent Bernat authored on 2014/10/20 22:33:17
Showing 1 changed files
... ...
@@ -195,17 +195,18 @@ __docker_subcommand () {
195 195
             ;;
196 196
         (build)
197 197
             _arguments \
198
-                '--force-rm[Always remove intermediate containers, even after unsuccessful builds]' \
198
+                '--force-rm[Always remove intermediate containers]' \
199 199
                 '--no-cache[Do not use cache when building the image]' \
200
-                '-q[Suppress verbose build output]' \
200
+                {-q,--quiet}'[Suppress verbose build output]' \
201 201
                 '--rm[Remove intermediate containers after a successful build]' \
202
-                '-t:repository:__docker_repositories_with_tags' \
202
+                {-t,--tag=-}'[Repository, name and tag to be applied]:repository:__docker_repositories_with_tags' \
203 203
                 ':path or URL:_directories'
204 204
             ;;
205 205
         (commit)
206 206
             _arguments \
207
-                '--author=-[Author]:author: ' \
208
-                '-m[Commit message]:message: ' \
207
+                {-a,--author=-}'[Author]:author: ' \
208
+                {-m,--message=-}'[Commit message]:message: ' \
209
+                {-p,--pause}'[Pause container during commit]' \
209 210
                 '--run=-[Configuration automatically applied when the image is run]:configuration: ' \
210 211
                 ':container:__docker_containers' \
211 212
                 ':repository:__docker_repositories_with_tags'
... ...
@@ -224,60 +225,40 @@ __docker_subcommand () {
224 224
                     ;;
225 225
             esac
226 226
             ;;
227
-        (create)
228
-            _arguments \
229
-                '-P[Publish all exposed ports to the host]' \
230
-                '-a[Attach to stdin, stdout or stderr]' \
231
-                '-c=-[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)' \
232
-                '--cidfile=-[Write the container ID to the file]:CID file:_files' \
233
-                '*--dns=-[Set custom dns servers]:dns server: ' \
234
-                '*-e=-[Set environment variables]:environment variable: ' \
235
-                '--entrypoint=-[Overwrite the default entrypoint of the image]:entry point: ' \
236
-                '*--expose=-[Expose a port from the container without publishing it]: ' \
237
-                '-h=-[Container host name]:hostname:_hosts' \
238
-                '-i[Keep stdin open even if not attached]' \
239
-                '--link=-[Add link to another container]:link:->link' \
240
-                '--lxc-conf=-[Add custom lxc options]:lxc options: ' \
241
-                '-m=-[Memory limit (in bytes)]:limit: ' \
242
-                '--name=-[Container name]:name: ' \
243
-                '*-p=-[Expose a container'"'"'s port to the host]:port:_ports' \
244
-                '--privileged[Give extended privileges to this container]' \
245
-                '-t[Allocate a pseudo-tty]' \
246
-                '-u=-[Username or UID]:user:_users' \
247
-                '*-v=-[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]:volume: '\
248
-                '--volumes-from=-[Mount volumes from the specified container]:volume: ' \
249
-                '-w=-[Working directory inside the container]:directory:_directories' \
250
-                '(-):images:__docker_images' \
251
-                '(-):command: _command_names -e' \
252
-                '*::arguments: _normal'
253 227
         (diff|export)
254 228
             _arguments '*:containers:__docker_containers'
255 229
             ;;
230
+        (events)
231
+            _arguments \
232
+                '--since=-[Events created since this timestamp]:timestamp: ' \
233
+                '--until=-[Events created until this timestamp]:timestamp: '
234
+            ;;
256 235
         (exec)
257 236
             _arguments \
258
-                '-d[Detached mode: leave the container running in the background]' \
259
-                '-i[Keep stdin open even if not attached]' \
260
-                '-t[Allocate a pseudo-tty]' \
237
+                {-d,--detach}'[Detached mode: leave the container running in the background]' \
238
+                {-i,--interactive}'[Keep stdin open even if not attached]' \
239
+                {-t,--tty}'[Allocate a pseudo-tty]' \
261 240
                 ':containers:__docker_runningcontainers'
262 241
             ;;
263 242
         (history)
264 243
             _arguments \
265 244
                 '--no-trunc[Do not truncate output]' \
266
-                '-q[Only show numeric IDs]' \
245
+                {-q,--quiet}'[Only show numeric IDs]' \
267 246
                 '*:images:__docker_images'
268 247
             ;;
269 248
         (images)
270 249
             _arguments \
271
-                '-a[Show all images]' \
250
+                {-a,--all}'[Show all images]' \
251
+                '*'{-f,--filter=-}'[Filter values]:filter: ' \
272 252
                 '--no-trunc[Do not truncate output]' \
273
-                '-q[Only show numeric IDs]' \
253
+                {-q,--quiet}'[Only show numeric IDs]' \
274 254
                 '--tree[Output graph in tree format]' \
275 255
                 '--viz[Output graph in graphviz format]' \
276 256
                 ':repository:__docker_repositories'
277 257
             ;;
278 258
         (inspect)
279 259
             _arguments \
280
-                '--format=-[Format the output using the given go template]:template: ' \
260
+                {-f,--format=-}'[Format the output using the given go template]:template: ' \
281 261
                 '*:containers:__docker_containers'
282 262
             ;;
283 263
         (import)
... ...
@@ -298,20 +279,29 @@ __docker_subcommand () {
298 298
                        '3:file:_files'
299 299
             ;;
300 300
         (kill)
301
-            _arguments '*:containers:__docker_runningcontainers'
301
+            _arguments \
302
+                {-s,--signal=-}'[Signal to send]:signal:_signals' \
303
+                '*:containers:__docker_runningcontainers'
302 304
             ;;
303 305
         (load)
306
+            _arguments \
307
+                {-i,--input=-}'[Read from tar archive file]:tar:_files'
304 308
             ;;
305 309
         (login)
306 310
             _arguments \
307
-                '-e[Email]:email: ' \
308
-                '-p[Password]:password: ' \
309
-                '-u[Username]:username: ' \
311
+                {-e,--email=-}'[Email]:email: ' \
312
+                {-p,--password=-}'[Password]:password: ' \
313
+                {-u,--user=-}'[Username]:username: ' \
314
+                ':server: '
315
+            ;;
316
+        (logout)
317
+            _arguments \
310 318
                 ':server: '
311 319
             ;;
312 320
         (logs)
313 321
             _arguments \
314
-                '-f[Follow log output]' \
322
+                {-f,--follow}'[Follow log output]' \
323
+                {-t,--timestamps}'[Show timestamps]' \
315 324
                 '*:containers:__docker_containers'
316 325
             ;;
317 326
         (port)
... ...
@@ -319,24 +309,32 @@ __docker_subcommand () {
319 319
                 '1:containers:__docker_runningcontainers' \
320 320
                 '2:port:_ports'
321 321
             ;;
322
+        (pause|unpause)
323
+            _arguments \
324
+                '1:containers:__docker_runningcontainers'
325
+            ;;
322 326
         (start)
323 327
             _arguments \
324
-                '-a[Attach container'"'"'s stdout/stderr and forward all signals]' \
325
-                '-i[Attach container'"'"'s stding]' \
328
+                {-a,--attach}'[Attach container'"'"'s stdout/stderr and forward all signals]' \
329
+                {-i,--interactive}'[Attach container'"'"'s stding]' \
326 330
                 '*:containers:__docker_stoppedcontainers'
327 331
             ;;
328 332
         (rm)
329 333
             _arguments \
330
-                '--link[Remove the specified link and not the underlying container]' \
331
-                '-v[Remove the volumes associated to the container]' \
334
+                {-f,--force}'[Force removal]' \
335
+                {-l,--link}'[Remove the specified link and not the underlying container]' \
336
+                {-v,--volumes}'[Remove the volumes associated to the container]' \
332 337
                 '*:containers:__docker_stoppedcontainers'
333 338
             ;;
334 339
         (rmi)
335 340
             _arguments \
341
+                {-f,--force}'[Force removal]' \
342
+                '--no-prune[Do not delete untagged parents]' \
336 343
                 '*:images:__docker_images'
337 344
             ;;
338 345
         (restart|stop)
339
-            _arguments '-t[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)' \
346
+            _arguments \
347
+                {-t,--time=-}'[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)' \
340 348
                 '*:containers:__docker_runningcontainers'
341 349
             ;;
342 350
         (top)
... ...
@@ -352,47 +350,58 @@ __docker_subcommand () {
352 352
             ;;
353 353
         (ps)
354 354
             _arguments \
355
-                '-a[Show all containers]' \
355
+                {-a,--all}'[Show all containers]' \
356 356
                 '--before=-[Show only container created before...]:containers:__docker_containers' \
357
-                '-l[Show only the latest created container]' \
357
+                '*'{-f,--filter=-}'[Filter values]:filter: ' \
358
+                {-l,--latest}'[Show only the latest created container]' \
358 359
                 '-n[Show n last created containers, include non-running one]:n:(1 5 10 25 50)' \
359 360
                 '--no-trunc[Do not truncate output]' \
360
-                '-q[Only show numeric IDs]' \
361
-                '-s[Display sizes]' \
361
+                {-q,--quiet}'[Only show numeric IDs]' \
362
+                {-s,--size}'[Display sizes]' \
362 363
                 '--since=-[Show only containers created since...]:containers:__docker_containers'
363 364
             ;;
364 365
         (tag)
365 366
             _arguments \
366
-                '-f[force]'\
367
+                {-f,--force}'[force]'\
367 368
                 ':image:__docker_images'\
368 369
                 ':repository:__docker_repositories_with_tags'
369 370
             ;;
370
-        (run)
371
+        (create|run)
371 372
             _arguments \
372
-                '-P[Publish all exposed ports to the host]' \
373
-                '-a[Attach to stdin, stdout or stderr]' \
374
-                '-c[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)' \
373
+                {-a,--attach}'[Attach to stdin, stdout or stderr]' \
374
+                '*--add-host=-[Add a custom host-to-IP mapping]:host\:ip mapping: ' \
375
+                {-c,--cpu-shares=-}'[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)' \
376
+                '*--cap-add=-[Add Linux capabilities]:capability: ' \
377
+                '*--cap-drop=-[Drop Linux capabilities]:capability: ' \
375 378
                 '--cidfile=-[Write the container ID to the file]:CID file:_files' \
376
-                '-d[Detached mode: leave the container running in the background]' \
379
+                '--cpuset=-[CPUs in which to allow execution]:CPU set: ' \
380
+                {-d,--detach}'[Detached mode: leave the container running in the background]' \
381
+                '*--device=-[Add a host device to the container]:device:_files' \
377 382
                 '*--dns=-[Set custom dns servers]:dns server: ' \
378
-                '*-e[Set environment variables]:environment variable: ' \
383
+                '*--dns-search=-[Set custom DNS search domains]:dns domains: ' \
384
+                '*'{-e,--environment=-}'[Set environment variables]:environment variable: ' \
379 385
                 '--entrypoint=-[Overwrite the default entrypoint of the image]:entry point: ' \
386
+                '*--env-file=-[Read environment variables from a file]:environment file:_files' \
380 387
                 '*--expose=-[Expose a port from the container without publishing it]: ' \
381
-                '-h[Container host name]:hostname:_hosts' \
382
-                '-i[Keep stdin open even if not attached]' \
383
-                '--link=-[Add link to another container]:link:->link' \
384
-                '--lxc-conf=-[Add custom lxc options]:lxc options: ' \
388
+                {-h,--hostname=-}'[Container host name]:hostname:_hosts' \
389
+                {-i,--interactive}'[Keep stdin open even if not attached]' \
390
+                '*--link=-[Add link to another container]:link:->link' \
391
+                '*--lxc-conf=-[Add custom lxc options]:lxc options: ' \
385 392
                 '-m[Memory limit (in bytes)]:limit: ' \
386 393
                 '--name=-[Container name]:name: ' \
387
-                '*-p[Expose a container'"'"'s port to the host]:port:_ports' \
394
+                '--net=-[Network mode]:network mode:(bridge none container: host)' \
395
+                {-P,--publish-all}'[Publish all exposed ports]' \
396
+                '*'{-p,--publish=-}'[Expose a container'"'"'s port to the host]:port:_ports' \
388 397
                 '--privileged[Give extended privileges to this container]' \
398
+                '--restart=-[Restart policy]:restart policy:(no on-failure always)' \
389 399
                 '--rm[Remove intermediate containers when it exits]' \
400
+                '*--security-opt=-[Security options]:security option: ' \
390 401
                 '--sig-proxy[Proxify all received signal]' \
391
-                '-t[Allocate a pseudo-tty]' \
392
-                '-u[Username or UID]:user:_users' \
393
-                '*-v[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]:volume: '\
394
-                '--volumes-from=-[Mount volumes from the specified container]:volume: ' \
395
-                '-w[Working directory inside the container]:directory:_directories' \
402
+                {-t,--tty}'[Allocate a pseudo-tty]' \
403
+                {-u,--user=-}'[Username or UID]:user:_users' \
404
+                '*-v[Bind mount a volume]:volume: '\
405
+                '*--volumes-from=-[Mount volumes from the specified container]:volume: ' \
406
+                {-w,--workdir=-}'[Working directory inside the container]:directory:_directories' \
396 407
                 '(-):images:__docker_images' \
397 408
                 '(-):command: _command_names -e' \
398 409
                 '*::arguments: _normal'
... ...
@@ -416,6 +425,7 @@ __docker_subcommand () {
416 416
             ;;
417 417
         (save)
418 418
             _arguments \
419
+                {-o,--output=-}'[Write to file]:file:_files' \
419 420
                 ':images:__docker_images'
420 421
             ;;
421 422
         (wait)